Skip to content

Commit

Permalink
toNurbsCurve(Arc) and Tranform(NurbsCurve)
Browse files Browse the repository at this point in the history
Implemented toNurbsCurve(Arc) and Tranform(NurbsCurve)
fixes #960
  • Loading branch information
alexradne committed May 16, 2019
1 parent 57027ae commit 6b61e94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 13 additions & 2 deletions Geometry_Engine/Convert/NurbsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,21 @@ public static partial class Convert
/**** Public Methods - Curves ****/
/***************************************************/

[NotImplemented]
public static NurbsCurve ToNurbsCurve(this Arc arc)
{
throw new NotImplementedException();
Point P0 = arc.StartPoint();
Point P2 = arc.EndPoint();
Point M = Query.Average(new List<Point>() { P0, P2 });
Point O = arc.CoordinateSystem.Origin;

double a = Math.PI/2 - Query.Angle(P0 - O, M - O);
Point P1 = O + (M - O).Normalise() * arc.Radius / Math.Sin(a);

return new NurbsCurve() {
ControlPoints = new List<Point>() { P0, P1, P2 },
Weights = new List<double>() { 1, Math.Sin(a), 1 },
Knots = new List<double>() { 0, 0, 1, 1 }
};
}

/***************************************************/
Expand Down
8 changes: 6 additions & 2 deletions Geometry_Engine/Modify/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ public static Line Transform(this Line line, TransformMatrix transform)

/***************************************************/

[NotImplemented]
public static NurbsCurve Transform(this NurbsCurve curve, TransformMatrix transform)
{
throw new NotImplementedException();
return new NurbsCurve()
{
ControlPoints = curve.ControlPoints.Select(cp => cp.Transform(transform)).ToList(),
Weights = curve.Weights,
Knots = curve.Knots
};
}


Expand Down

0 comments on commit 6b61e94

Please sign in to comment.