Represents a cubic bezier curve with two anchor and two control points. More...
Public Member Functions | |
| BezierCurveCubic (Vector2 startAnchor, Vector2 endAnchor, Vector2 firstControlPoint, Vector2 secondControlPoint) | |
| Constructs a new BezierCurveCubic. | |
| BezierCurveCubic (float parallel, Vector2 startAnchor, Vector2 endAnchor, Vector2 firstControlPoint, Vector2 secondControlPoint) | |
| Constructs a new BezierCurveCubic. | |
| Vector2 | CalculatePoint (float t) |
| Calculates the point with the specified t. | |
| float | CalculateLength (float precision) |
| Calculates the length of this bezier curve. | |
Public Attributes | |
| Vector2 | StartAnchor |
| Start anchor point. | |
| Vector2 | EndAnchor |
| End anchor point. | |
| Vector2 | FirstControlPoint |
| First control point, controls the direction of the curve start. | |
| Vector2 | SecondControlPoint |
| Second control point, controls the direction of the curve end. | |
| float | Parallel |
| Gets or sets the parallel value. | |
Represents a cubic bezier curve with two anchor and two control points.
Definition at line 21 of file BezierCurveCubic.cs.
| OpenTK.BezierCurveCubic.BezierCurveCubic | ( | Vector2 | startAnchor, | |
| Vector2 | endAnchor, | |||
| Vector2 | firstControlPoint, | |||
| Vector2 | secondControlPoint | |||
| ) |
Constructs a new BezierCurveCubic.
| startAnchor | The start anchor point. | |
| endAnchor | The end anchor point. | |
| firstControlPoint | The first control point. | |
| secondControlPoint | The second control point. |
Definition at line 65 of file BezierCurveCubic.cs.
00066 { 00067 this.StartAnchor = startAnchor; 00068 this.EndAnchor = endAnchor; 00069 this.FirstControlPoint = firstControlPoint; 00070 this.SecondControlPoint = secondControlPoint; 00071 this.Parallel = 0.0f; 00072 }
| OpenTK.BezierCurveCubic.BezierCurveCubic | ( | float | parallel, | |
| Vector2 | startAnchor, | |||
| Vector2 | endAnchor, | |||
| Vector2 | firstControlPoint, | |||
| Vector2 | secondControlPoint | |||
| ) |
Constructs a new BezierCurveCubic.
| parallel | The parallel value. | |
| startAnchor | The start anchor point. | |
| endAnchor | The end anchor point. | |
| firstControlPoint | The first control point. | |
| secondControlPoint | The second control point. |
Definition at line 82 of file BezierCurveCubic.cs.
00083 { 00084 this.Parallel = parallel; 00085 this.StartAnchor = startAnchor; 00086 this.EndAnchor = endAnchor; 00087 this.FirstControlPoint = firstControlPoint; 00088 this.SecondControlPoint = secondControlPoint; 00089 }
| float OpenTK.BezierCurveCubic.CalculateLength | ( | float | precision | ) |
Calculates the length of this bezier curve.
| precision | The precision. |
The precision gets better when the precision value gets smaller.
Definition at line 146 of file BezierCurveCubic.cs.
00147 { 00148 float length = 0.0f; 00149 Vector2 old = CalculatePoint(0.0f); 00150 00151 for (float i = precision; i < (1.0f + precision); i += precision) 00152 { 00153 Vector2 n = CalculatePoint(i); 00154 length += (n - old).Length; 00155 old = n; 00156 } 00157 00158 return length; 00159 }
| Vector2 OpenTK.BezierCurveCubic.CalculatePoint | ( | float | t | ) |
Calculates the point with the specified t.
| t | The t value, between 0.0f and 1.0f. |
Definition at line 100 of file BezierCurveCubic.cs.
00101 { 00102 Vector2 r = new Vector2(); 00103 float c = 1.0f - t; 00104 00105 r.X = (StartAnchor.X * c * c * c) + (FirstControlPoint.X * 3 * t * c * c) + (SecondControlPoint.X * 3 * t * t * c) 00106 + EndAnchor.X * t * t * t; 00107 r.Y = (StartAnchor.Y * c * c * c) + (FirstControlPoint.Y * 3 * t * c * c) + (SecondControlPoint.Y * 3 * t * t * c) 00108 + EndAnchor.Y * t * t * t; 00109 00110 if (Parallel == 0.0f) 00111 return r; 00112 00113 Vector2 perpendicular = new Vector2(); 00114 00115 if (t == 0.0f) 00116 perpendicular = FirstControlPoint - StartAnchor; 00117 else 00118 perpendicular = r - CalculatePointOfDerivative(t); 00119 00120 return r + Vector2.Normalize(perpendicular).PerpendicularRight * Parallel; 00121 }
End anchor point.
Definition at line 33 of file BezierCurveCubic.cs.
First control point, controls the direction of the curve start.
Definition at line 38 of file BezierCurveCubic.cs.
Gets or sets the parallel value.
This value defines whether the curve should be calculated as a parallel curve to the original bezier curve. A value of 0.0f represents the original curve, 5.0f i.e. stands for a curve that has always a distance of 5.f to the orignal curve at any point.
Definition at line 52 of file BezierCurveCubic.cs.
Second control point, controls the direction of the curve end.
Definition at line 43 of file BezierCurveCubic.cs.
Start anchor point.
Definition at line 28 of file BezierCurveCubic.cs.
1.6.1