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(Single)
Convert Angle in Degrees to Angle in Radians
Declaration
float DegressToRadians(float radians)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | radians | Angle to convert in radians |
Returns
| Type | Description |
|---|---|
| System.Single |
LineAndArrowVertexAndIndicesGenerator(Vector2, Vector2, Single, Boolean, Boolean, Int32, Boolean, Single, Single)
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 = 10F, float headWidth = 10F)
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) |
| System.Single | width | Width of the line (thickness) |
| System.Boolean | rounded | Whether the line / arrow as rounded ends |
| System.Boolean | 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 |
| System.Int32 | numberOfCurveSegments | Number of segments that a rounded end is divided up into |
| System.Boolean | isArrow | |
| System.Single | headLength | How long the arrow head is (aslong as the total arrow length can support it) |
| System.Single | headWidth | Width arrow head at the widest point |
Returns
| Type | Description |
|---|---|
| Tuple<Vector2[], System.Int32[]> |
RadiansToDegrees(Single)
Convert Angle in Radians to Angle in Degress
Declaration
float RadiansToDegrees(float degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | degrees | Angle to convert in degrees |
Returns
| Type | Description |
|---|---|
| System.Single |
RegularPolygonVertexAndIndicesGenerator(Vector2, Int32, Single)
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 |
| System.Int32 | numSides | The number of sides that polygon has (minimum 3 == triangle) |
| System.Single | radius | Distance of each outer edge vertex point from centre |
Returns
| Type | Description |
|---|---|
| Tuple<Vector2[], System.Int32[]> |
RotateVectorClockwise(Vector2, Single)
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 | |
| System.Single | radians | Clockwise rotation angle in radians |
Returns
| Type | Description |
|---|---|
| Vector2 |
RotateVectorClockwise(ref Vector2, Single)
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 | |
| System.Single | radians | Clockwise rotation angle in radians |
Returns
| Type | Description |
|---|---|
| Vector2 |