githubEdit

PolygonZone

package com.skeletonarmy.marrow.zones

Overview

PolygonZone defines a multi-point polygon region for representing triangular, rectangular, or arbitrary-shaped areas.

A common use case is representing the robot as a PolygonZone.


Usage

PolygonZone offers multiple constructors:

// --- Triangle defined by three corners ---
PolygonZone triangle = new PolygonZone(
    new Point(0, 0),
    new Point(12, 0),
    new Point(12, 6)
);

// --- Rectangle defined by width and height ---
PolygonZone unitRect = new PolygonZone(10, 5);

// --- Rectangle centered at a point ---
PolygonZone centered = new PolygonZone(new Point(24, 24), 12, 6);

// --- Rotated rectangle centered at a point ---
PolygonZone rotated = new PolygonZone(new Point(24, 24), 12, 6, Math.toRadians(45));

// --- Thin rectangular line between two points with a thickness ---
PolygonZone line = new PolygonZone(new Point(4, 4), new Point(10, 10), 5);

PolygonZone can also be used to represent the robot as a zone:


Unique Methods

PolygonZone provides methods specific to polygon geometry:

Method
Description

double getRotation()

Gets the current rotation of the polygon in radians.

double getRotationDegrees()

Gets the current rotation of the polygon in degrees.

void rotateBy(double angleRadians)

Rotates the polygon around its center by the given angle in radians.

void rotateByDegrees(double angleDegrees)

Rotates the polygon around its center by the given angle in degrees.

void setRotation(double angleRadians)

Sets the polygon rotation to the specified angle in radians.

void setRotationDegrees(double angleDegrees)

Sets the polygon rotation to the specified angle in degrees.

Last updated