Class DegreeConstants
Utility methods for geometric calculations involving degrees or polar coordinates.
Namespace: AS2.Visuals.Library
Assembly: .dll
Syntax
public static class DegreeConstants
Methods
CartesianToPolar(Vector2, float)
Converts the given Cartesian coordinates to polar coordinates.
0 degrees are east, counterclockwise rotation is positive.
The absolute value of the angle will never be greater than
180
. Coordinates with a negative Y component will have
a negative angle instead.
Declaration
public static Tuple<double, double> CartesianToPolar(Vector2 coordinate, float degreeOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | coordinate | The Cartesian coordinates to be converted. |
float | degreeOffset | The angle in degrees that should be subtracted from the resulting polar angle. |
Returns
Type | Description |
---|---|
Tuple<double, double> | The polar coordinates corresponding to the given Cartesian coordinates and offset. |
ManuallyImplementedSignedOrthogonalDistancesOfPointToLineFromAToB(Vector2, Vector2, Vector2)
Calculates the signed orthogonal distance from a line to a point.
Declaration
public static float ManuallyImplementedSignedOrthogonalDistancesOfPointToLineFromAToB(Vector2 point, Vector2 linePoint1, Vector2 linePoint2)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point | The point. |
Vector2 | linePoint1 | First point of the line. |
Vector2 | linePoint2 | Second point of the line. Should not be equal to the first point. |
Returns
Type | Description |
---|---|
float |
PolarToCartesian(double, double, float)
Converts the given polar coordinates to Cartesian
coordinates. 0 degrees are east, counterclockwise
rotation is positive. The given degreeOffset
is added to the coordinate angle before the conversion,
e.g., an offset of 90 makes a 0 degree angle point up.
Declaration
public static Vector2 PolarToCartesian(double degree, double radius, float degreeOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
double | degree | The angle of the polar coordinate in degrees. |
double | radius | The radius of the polar coordinate. |
float | degreeOffset | The angle to be added to
|
Returns
Type | Description |
---|---|
Vector2 | The Cartesian coordinates corresponding to the given polar coordinates. |