Interface ICommonOperations
Angle conversion, 2d vector rotation and helpers for generating line, arrow and regular polygon vertex positions and indices lists
Namespace: Yak2D
Assembly: Yak2D.Api.dll
Syntax
public interface ICommonOperations
Methods
DegressToRadians(float)
Convert Angle in Degrees to Angle in Radians
Declaration
float DegressToRadians(float radians)
Parameters
| Type | Name | Description |
|---|---|---|
| float | radians | Angle to convert in radians |
Returns
| Type | Description |
|---|---|
| float |
LineAndArrowVertexAndIndicesGenerator(Vector2, Vector2, float, bool, bool, int, bool, float, float)
Returns tuple containing the position vectors and draw order indices a line or arrow
Declaration
Tuple<Vector2[], int[]> LineAndArrowVertexAndIndicesGenerator(Vector2 start, Vector2 end, float width, bool rounded = false, bool centreOfCurveRadiusAtLineEndPoints = true, int numberOfCurveSegments = 32, bool isArrow = false, float headLength = 10, float headWidth = 10)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | start | Location of the start of the line/arrow (middle of the line's thickness) |
| Vector2 | end | Location of the end of the line/arrow (middle of the line's thickness or arrow head point) |
| float | width | Width of the line (thickness) |
| bool | rounded | Whether the line / arrow as rounded ends |
| bool | centreOfCurveRadiusAtLineEndPoints | Whether the start and end points represent the centre of a rounded end's radius. False implies the line / arrow has no vertices more extreme than the start / end points |
| int | numberOfCurveSegments | Number of segments that a rounded end is divided up into |
| bool | isArrow | |
| float | headLength | How long the arrow head is (aslong as the total arrow length can support it) |
| float | headWidth | Width arrow head at the widest point |
Returns
| Type | Description |
|---|---|
| Tuple<Vector2[], int[]> |
RadiansToDegrees(float)
Convert Angle in Radians to Angle in Degress
Declaration
float RadiansToDegrees(float degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| float | degrees | Angle to convert in degrees |
Returns
| Type | Description |
|---|---|
| float |
RegularPolygonVertexAndIndicesGenerator(Vector2, int, float)
Returns tuple containing the position vectors and draw order indices a regular polygon
Declaration
Tuple<Vector2[], int[]> RegularPolygonVertexAndIndicesGenerator(Vector2 position, int numSides, float radius)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | Centre position of the polygon |
| int | numSides | The number of sides that polygon has (minimum 3 == triangle) |
| float | radius | Distance of each outer edge vertex point from centre |
Returns
| Type | Description |
|---|---|
| Tuple<Vector2[], int[]> |
RotateVectorClockwise(Vector2, float)
Returns vector that is the input vector rotated clockwise by the requests angle in radians
Declaration
Vector2 RotateVectorClockwise(Vector2 v, float radians)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | v | |
| float | radians | Clockwise rotation angle in radians |
Returns
| Type | Description |
|---|---|
| Vector2 |
RotateVectorClockwise(ref Vector2, float)
Returns vector that is the input vector rotated clockwise by the requests angle in radians
Declaration
Vector2 RotateVectorClockwise(ref Vector2 v, float radians)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | v | |
| float | radians | Clockwise rotation angle in radians |
Returns
| Type | Description |
|---|---|
| Vector2 |