diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bc73d5a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: csharp -mono: none -sudo: required -dist: xenial -dotnet: 3.0 - -script: - - dotnet restore - - dotnet build -c Release - - dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/opencover.xml - -after_success: - - bash <(curl -s https://codecov.io/bash) -f "coverage/opencover.xml" - -branches: - only: - - master - - develop - - feature/* - -notifications: - slack: paramdigma:FtUcdwSDOynOHw2M479kXHxs#geometry-library diff --git a/src/Collections/Matrix{T}.cs b/src/Collections/Matrix{T}.cs index a5ab072..e9570bb 100644 --- a/src/Collections/Matrix{T}.cs +++ b/src/Collections/Matrix{T}.cs @@ -56,6 +56,11 @@ public class Matrix /// Column. public ref T this[int row, int column] => ref this.data[row, column]; + /// + /// Gets the amount of items in this matrix. + /// + public int Count => this.data.Length; + /// /// Get the row of a matrix at the specified index. @@ -86,11 +91,7 @@ public T[] Column(int m) return col; } - /// - /// Gets the amount of items in this matrix. - /// - public int Count => this.data.Length; - + // ----- ORDERING METHODS ----- diff --git a/src/Geometry/2D/BoundingBox2d.cs b/src/Geometry/2D/BoundingBox2d.cs index 8b09639..a6c7a8e 100644 --- a/src/Geometry/2D/BoundingBox2d.cs +++ b/src/Geometry/2D/BoundingBox2d.cs @@ -9,6 +9,7 @@ public class BoundingBox2d { /// /// Initializes a new instance of the class from 2 points. + /// Coordinates will automatically be corrected if the corners are not consistent with naming (i.e. bottomLeftCorner is actually topLeft..) /// /// Bottom left corner. /// Top right corner. @@ -90,23 +91,23 @@ public BoundingBox2d(Polyline2d polyline) public Point2d TopRight => new Point2d(this.XDomain.End, this.YDomain.End); /// - /// Gets the midpoint at the left edge of the box. + /// Gets the midpoint at the left edge of the box. /// public Point2d MidLeft => new Point2d(this.XDomain.Start, this.YDomain.RemapFromUnit(0.5)); /// - /// Gets the midpoint at the right edge of the box. + /// Gets the midpoint at the right edge of the box. /// public Point2d MidRight => new Point2d(this.XDomain.End, this.YDomain.RemapFromUnit(0.5)); /// - /// Gets the midpoint at the bottom edge of the box. + /// Gets the midpoint at the bottom edge of the box. /// public Point2d MidBottom => new Point2d(this.XDomain.RemapFromUnit(0.5), this.YDomain.Start); /// - /// Gets the midpoint at the top edge of the box. + /// Gets the midpoint at the top edge of the box. /// public Point2d MidTop => new Point2d(this.XDomain.RemapFromUnit(0.5), this.YDomain.End); @@ -116,17 +117,18 @@ public BoundingBox2d(Polyline2d polyline) public Point2d Center => new Point2d(this.XDomain.RemapFromUnit(0.5), this.YDomain.RemapFromUnit(0.5)); - + /// - /// Checks if a point is contained inside the box. + /// Checks if a point is contained inside the box. /// /// Point to test containment. /// True if point is contained inside the bounding box. public bool ContainsPoint(Point2d pt) => this.XDomain.Contains(pt.X) && this.YDomain.Contains(pt.Y); + /// - /// Checks if a box intersects with this instance. + /// Checks if a box intersects with this instance. /// /// Box to check intersection against. /// True if intersection exists. diff --git a/src/Geometry/2D/Polyline2d.cs b/src/Geometry/2D/Polyline2d.cs index 07e7c07..6197355 100644 --- a/src/Geometry/2D/Polyline2d.cs +++ b/src/Geometry/2D/Polyline2d.cs @@ -34,16 +34,7 @@ public Polyline2d(List vertices, bool closed) /// Gets or sets the polyline vertices. /// /// List of vertices. - public List Vertices - { - get => this.vertices; - - set - { - this.vertices = value; - this.segmentsNeedUpdate = true; - } - } + public List Vertices => this.vertices; /// /// Gets the polyline segments. @@ -153,7 +144,7 @@ public bool IsClockwise() { if (this.vertices[i].Y > ymin) continue; - + if (Math.Abs(this.vertices[i].Y - ymin) < Settings.Tolerance && this.vertices[i].X < xmin) continue; diff --git a/src/Geometry/3D/Circle.cs b/src/Geometry/3D/Circle.cs index 60b54ba..b76bcb1 100644 --- a/src/Geometry/3D/Circle.cs +++ b/src/Geometry/3D/Circle.cs @@ -4,22 +4,23 @@ namespace Paramdigma.Core.Geometry { /// - /// Represents a planar circle curve. + /// Represents a planar circle curve. /// public class Circle : ICurve { /// - /// The base plane for the circle. + /// The base plane for the circle. /// public Plane Plane; - + /// - /// The radius of the circle. + /// The radius of the circle. /// public double Radius; + /// - /// Initializes a new instance of by it's plane and radius. + /// Initializes a new instance of by it's plane and radius. /// /// The plane to draw the circle at. /// The desired radius of the circle. diff --git a/src/Geometry/3D/Line.cs b/src/Geometry/3D/Line.cs index 48c7f14..0a317c9 100644 --- a/src/Geometry/3D/Line.cs +++ b/src/Geometry/3D/Line.cs @@ -118,7 +118,7 @@ public override Vector3d BinormalAt(double t) => /// - /// Explicitly converts a line to it's vector representation. + /// Explicitly converts a line to it's vector representation. /// /// Line to convert. /// Vector defining the line direction and length. diff --git a/src/Geometry/3D/Mesh/Mesh.cs b/src/Geometry/3D/Mesh/Mesh.cs index 0fe9944..ccefdf0 100644 --- a/src/Geometry/3D/Mesh/Mesh.cs +++ b/src/Geometry/3D/Mesh/Mesh.cs @@ -484,10 +484,10 @@ private bool CreateFaces(IEnumerable> faceIndexes) boundaryHalfEdge.Vertex = nextHalfEdge.Vertex; boundaryHalfEdge.Edge = halfEdge.Edge; boundaryHalfEdge.OnBoundary = true; - + boundaryHalfEdge.Face = f; f.HalfEdge = boundaryHalfEdge; - + boundaryHalfEdge.Twin = halfEdge; halfEdge.Twin = boundaryHalfEdge; @@ -506,7 +506,7 @@ private bool CreateFaces(IEnumerable> faceIndexes) if (h.OnBoundary) continue; - + var corner = new MeshCorner {HalfEdge = h}; h.Corner = corner; this.Corners.Add(corner); diff --git a/src/Geometry/3D/Mesh/MeshTopology.cs b/src/Geometry/3D/Mesh/MeshTopology.cs index 19e70ea..b985c3b 100644 --- a/src/Geometry/3D/Mesh/MeshTopology.cs +++ b/src/Geometry/3D/Mesh/MeshTopology.cs @@ -29,6 +29,10 @@ public MeshTopology(Mesh mesh) this.EdgeVertex = new Dictionary>(); this.EdgeFace = new Dictionary>(); this.EdgeEdge = new Dictionary>(); + + this.ComputeEdgeAdjacency(); + this.ComputeFaceAdjacency(); + this.ComputeVertexAdjacency(); } diff --git a/src/Geometry/3D/NurbsCalculator.cs b/src/Geometry/3D/NurbsCalculator.cs index c5b38ad..c0def04 100644 --- a/src/Geometry/3D/NurbsCalculator.cs +++ b/src/Geometry/3D/NurbsCalculator.cs @@ -9,7 +9,7 @@ namespace Paramdigma.Core.Geometry /// Contains all methods related to 'The Nurbs Book 2nd Edition' implementation of NURBS curves and /// surfaces. /// - public static class NurbsCalculator + internal static class NurbsCalculator { /// /// Constructs a Unit knot vector given a point count and degree. @@ -209,7 +209,7 @@ public static Point3d DeCasteljau2( /// The knot span index. public static int FindSpan(int n, int degree, double t, IList knotVector) { - if (t >= knotVector[n+1]) + if (t >= knotVector[n + 1]) return n; var low = degree; @@ -586,6 +586,17 @@ public static Point3d CurvePoint( } + /// + /// Computes the derivatives of a rational b-spline curve at the specified parameter. + /// Algorithm A3.2 of 'The Nurbs Book' + /// + /// Control point count + 1 + /// Degree + /// The curve's knot vector. + /// The curve's control points + /// Parameter to compute derivatives at. + /// Number of derivatives to compute. + /// public static Vector3d[] CurveDerivsAlg1( int n, int p, @@ -611,6 +622,17 @@ public static Vector3d[] CurveDerivsAlg1( } + /// + /// Computes the derivatives of a non-rational b-spline curve at the specified parameter. + /// Algorithm A3.2 of 'The Nurbs Book' modified to accept instances.. + /// + /// Control point count + 1 + /// Degree + /// The curve's knot vector. + /// The curve's control points + /// Parameter to compute derivatives at. + /// Number of derivatives to compute. + /// public static Point4d[] CurveDerivsAlg1( int n, int p, @@ -636,6 +658,18 @@ public static Point4d[] CurveDerivsAlg1( } + /// + /// Computes the control points of all derivative curves up to and including the dth derivative. + /// Algorithm A3.3 of 'The Nurbs Book' + /// + /// + /// + /// + /// + /// + /// + /// + /// public static Point3d[,] CurveDerivCpts( int n, int p, @@ -664,6 +698,17 @@ public static Point4d[] CurveDerivsAlg1( } + /// + /// Computes the derivatives of a rational b-spline curve at the specified parameter. + /// Algorithm A3.4 of 'The Nurbs Book' + /// + /// Control point count + 1 + /// Degree + /// The curve's knot vector. + /// The curve's control points + /// Parameter to compute derivatives at. + /// Number of derivatives to compute. + /// The point on a B- spline curve and all derivatives up to and including the dth derivative at a fixed u value. public static Vector3d[] CurveDerivsAlg2( int n, int p, @@ -697,11 +742,9 @@ public static Vector3d[] CurveDerivsAlg2( } - // B-Spline Surfaces - - /// /// Computes a point on a nurbs surface. + /// Algorithm A3.5 of 'The Nurbs Book' /// /// /// @@ -743,6 +786,21 @@ public static Point3d SurfacePoint( } + /// + /// Computes the derivatives of at S(u,v) k times with respect to u and l times with respect to v. + /// Algorithm A3.6 of 'The Nurbs Book' + /// + /// Control point count - 1 in the U direction. + /// Degree in the U direction. + /// Knot vector in the U direction. + /// Control point count - 1 in the V direction. + /// Degree in the V direction. + /// Knot vector in the V direction. + /// Control point grid of the surface. + /// U parameter to get derivatives at. + /// V parameter to get derivatives at. + /// Number of derivatives to compute in each direction. + /// A multi dimensional array where [k,l] represents the derivative of S(u,v) with respect to u 'k' times, and v 'l' times. public static Point3d[,] SurfaceDerivsAlg1( int n, int p, @@ -801,6 +859,21 @@ public static Point3d SurfacePoint( } + /// + /// Computes the derivatives of at S(u,v) k times with respect to u and l times with respect to v. + /// Algorithm A3.6 of 'The Nurbs Book' modified to accept instances. + /// + /// Control point count - 1 in the U direction. + /// Degree in the U direction. + /// Knot vector in the U direction. + /// Control point count - 1 in the V direction. + /// Degree in the V direction. + /// Knot vector in the V direction. + /// Control point grid of the surface. + /// U parameter to get derivatives at. + /// V parameter to get derivatives at. + /// Number of derivatives to compute in each direction. + /// A multi dimensional array where [k,l] represents the derivative of S(u,v) with respect to u 'k' times, and v 'l' times. public static Point4d[,] SurfaceDerivsAlg1( int n, int p, @@ -835,11 +908,10 @@ public static Point3d SurfacePoint( for (var k = 0; k <= du; k++) { - var temp = new Point4d[q+1]; + var temp = new Point4d[q + 1]; for (var index = 0; index < temp.Length; index++) - { temp[index] = new Point4d(); - } + for (var s = 0; s <= q; s++) { temp[s] = new Point4d(); @@ -863,6 +935,22 @@ public static Point3d SurfacePoint( } + /// + /// Algorithm A3.7 of 'The Nurbs Book' + /// + /// Control point count - 1 in the U direction. + /// Degree in the U direction. + /// Knot vector in the U direction. + /// Control point count - 1 in the V direction. + /// Degree in the V direction. + /// Knot vector in the V direction. + /// Control point grid of the surface. + /// Number of derivatives to compute. + /// + /// + /// + /// + /// Computed derivatives at S(u,v). public static Point3d[][][][] SurfaceDerivCpts( int n, int p, @@ -926,6 +1014,20 @@ public static Point3d[][][][] SurfaceDerivCpts( } + /// + /// Algorithm A3.8 of 'The Nurbs Book' + /// + /// Control point count - 1 in the U direction. + /// Degree in the U direction. + /// Knot vector in the U direction. + /// Control point count - 1 in the V direction. + /// Degree in the V direction. + /// Knot vector in the V direction. + /// Control point grid of the surface. + /// U parameter to get derivatives at. + /// V parameter to get derivatives at. + /// Number of derivatives to compute in each direction. + /// A multi dimensional array where [k,l] represents the derivative of S(u,v) with respect to u 'k' times, and v 'l' times. public static Point3d[,] SurfaceDerivsAlg2( int n, int p, @@ -992,11 +1094,9 @@ public static Point3d[][][][] SurfaceDerivCpts( } - // Nubs methods - - /// - /// Computes a point on a nurbs curve + /// Computes a point on a nurbs curve + /// Algorithm A4.1 of 'The Nurbs Book' /// /// Number of control points - 1 /// Degree. Cannot be bigger or equals the number of control points, nor smaller than 1. @@ -1020,6 +1120,12 @@ public static Point3d CurvePoint( } + /// + /// Computes a binomial coefficient of a NURBS curve. + /// + /// + /// + /// Computed coefficient. public static double BinomialCoefficient(int n, int k) { if (n - k == 1 || k == 1) @@ -1027,32 +1133,40 @@ public static double BinomialCoefficient(int n, int k) var b = new double[n + 1, n - k + 1]; for (var i = 1; i < b.GetLength(0); i++) + { for (var j = 0; j < b.GetLength(1); j++) + { if (i == j || j == 0) b[i, j] = 1; else if (j == 1 || i - j == 1) b[i, j] = i; else b[i, j] = b[i - 1, j - 1] + b[i - 1, j]; + } + } return b[n, n - k]; } - public static bool IsClamped(IList u, int p) - { - return (u[0] == u[p]) && (u[u.Count - 1] == u[u.Count - 1 - p]); - } + /// + /// Determines if a knot vector is clamped. + /// + /// Knot vector. + /// Degree. + /// True if knot vector is clamped. + public static bool IsClamped(IList u, int p) => + u[0] == u[p] && u[u.Count - 1] == u[u.Count - 1 - p]; /// /// Compute C(u) derivatives from Cw(u) derivatives. - /// + /// Algorithm A4.2 of 'The Nurbs Book' /// - /// TODO Add definition - /// TODO: Add definition - /// TODO: add definition - /// + /// Position derivatives. + /// Weight derivatives. + /// Derivative count. + /// Computed derivatives. public static Vector3d[] RatCurveDerivs(IList aDers, IList wDers, int d) { var ders = new Vector3d[d + 1]; @@ -1081,19 +1195,13 @@ public static Vector3d[] NurbsCurveDerivs( var ck1 = CurveDerivsAlg1(n, p, knotVector, controlPoints, u, d); var aDers = ck1.Select(der => ( Vector3d ) der.Position).ToList(); var wDers = ck1.Select(der => der.Weight).ToList(); - var ck = RatCurveDerivs(aDers, wDers, d); - - return ck; - - // if (p == 1) - // ck[2] = new Vector3d(); - // - // return new []{ ck[0], ck[1], ck[2]}; + return RatCurveDerivs(aDers, wDers, d); } /// /// Compute a point on a nurbs surface. + /// Algorithm A4.3 of 'The Nurbs Book' /// /// The number of control points in the U direction - 1 /// The degree of the surface in the U direction. @@ -1104,7 +1212,7 @@ public static Vector3d[] NurbsCurveDerivs( /// A 2-dimensional matrix/grid of control points. /// Parameter to compute the point at in the U direction. /// Parameter to compute the point at in the V direction. - /// A instance with the result. + /// A instance with the result. public static Point3d SurfacePoint( int n, int p, @@ -1137,6 +1245,14 @@ public static Point3d SurfacePoint( } + /// + /// Computes the derivatives of a non-rational b-spline curve from the decomposed derivatives of a rational surface. + /// Algorithm A4.4 of 'The Nurbs Book' + /// + /// Position derivatives + /// Weight derivatives + /// Derivative count. + /// Computed derivatives at S(u,v) public static Matrix RatSurfaceDerivs( Matrix aDers, Matrix wDers, @@ -1144,8 +1260,10 @@ public static Matrix RatSurfaceDerivs( { var skl = new Matrix(wDers.M, wDers.N); for (var m = 0; m < wDers.M; m++) + { for (var n = 0; n < wDers.N; n++) - skl[m,n] = new Vector3d(); + skl[m, n] = new Vector3d(); + } var a = wDers.M - 1; var b = wDers.N - 1; @@ -1157,18 +1275,18 @@ public static Matrix RatSurfaceDerivs( var v = aDers[k, l]; for (var j = 0; j <= l; j++) v -= BinomialCoefficient(l, j) * wDers[0, j] * skl[k, l - j]; - - for (int i = 0; i <= k; i++) + + for (var i = 0; i <= k; i++) { v -= BinomialCoefficient(k, i) * wDers[i, 0] * skl[k - i, l]; var v2 = new Vector3d(); - for (int j = 0; j <= l; j++) + for (var j = 0; j <= l; j++) v2 += BinomialCoefficient(l, j) * wDers[i, j] * skl[k - i, l - j]; v -= BinomialCoefficient(k, i) * v2; } - skl[k, l] = v / wDers[0,0]; + skl[k, l] = v / wDers[0, 0]; } } @@ -1176,6 +1294,20 @@ public static Matrix RatSurfaceDerivs( } + /// + /// Compute C(u) derivatives from Cw(u) derivatives. + /// + /// The number of control points in the U direction - 1 + /// The degree of the surface in the U direction. + /// The knot vector for the U direction. + /// The number of control points in the V direction - 1 + /// The degree of the surface in the V direction. + /// The knot vector for the V direction. + /// A 2-dimensional matrix/grid of control points. + /// U parameter. + /// V parameter. + /// Derivative count. + /// Computed derivatives. public static Matrix NurbsSurfaceDerivs( int n, int p, @@ -1199,15 +1331,15 @@ public static Matrix NurbsSurfaceDerivs( u, v, d); - - var aDers = new Matrix(skl1.GetLength(0) + 1,skl1.GetLength(1) + 1); - var wDers = new Matrix(skl1.GetLength(0) + 1,skl1.GetLength(1) + 1); - + + var aDers = new Matrix(skl1.GetLength(0) + 1, skl1.GetLength(1) + 1); + var wDers = new Matrix(skl1.GetLength(0) + 1, skl1.GetLength(1) + 1); + for (var i = 0; i < controlPoints.M - 1; i++) { for (var j = 0; j < controlPoints.N - 1; j++) { - wDers[i, j] = controlPoints[i, j ].Weight; + wDers[i, j] = controlPoints[i, j].Weight; aDers[i, j] = controlPoints[i, j].Position; } } diff --git a/src/Geometry/3D/NurbsCurve.cs b/src/Geometry/3D/NurbsCurve.cs index a19d0dd..a940d35 100644 --- a/src/Geometry/3D/NurbsCurve.cs +++ b/src/Geometry/3D/NurbsCurve.cs @@ -9,30 +9,31 @@ namespace Paramdigma.Core.Geometry public class NurbsCurve : BaseCurve { /// - /// The control points of the nurbs curve. + /// The control points of the nurbs curve. /// public List ControlPoints; /// - /// The degree of the curve. + /// The degree of the curve. /// public int Degree; /// - /// The nurbs curve knot vector. + /// The nurbs curve knot vector. /// public List Knots; /// - /// Initializes a new instance of by it's control points and degree. + /// Initializes a new instance of by it's control points and degree. /// /// The control points to create the curve with. /// The desired degree of the curve. Degree cannot be > (ControlPoints - 1) public NurbsCurve(List controlPoints, int degree) { this.ControlPoints = controlPoints; - this.Knots = NurbsCalculator.CreateUniformKnotVector(controlPoints.Count, degree).ToList(); + this.Knots = NurbsCalculator.CreateUniformKnotVector(controlPoints.Count, degree) + .ToList(); this.Degree = degree; } diff --git a/src/Geometry/3D/NurbsSurface.cs b/src/Geometry/3D/NurbsSurface.cs index a273912..6c34225 100644 --- a/src/Geometry/3D/NurbsSurface.cs +++ b/src/Geometry/3D/NurbsSurface.cs @@ -38,7 +38,7 @@ public class NurbsSurface : ISurface /// - /// Initializes a new instance of by it's control points and degrees. + /// Initializes a new instance of by it's control points and degrees. /// /// Grid of control points for the surface. /// Degree of the surface in the U direction. @@ -59,31 +59,6 @@ public NurbsSurface(Matrix controlPoints, int degreeU, int degreeV) } - public static NurbsSurface CreateFlatSurface( - Interval xDimension, - Interval yDimension, - int xCount, - int yCount) - { - var rnd = new Random(); - var wDomain = new Interval(1, 5); - var m = new Matrix(xCount, yCount); - for (var i = 0; i < xCount; i++) - { - for (var j = 0; j < yCount; j++) - m[i, j] = new Point4d( - xDimension.RemapFromUnit(( double ) i / xCount), - yDimension.RemapFromUnit(( double ) j / yCount), - 0, - 1); - } - - var degreeU = xCount <= 3 ? xCount - 1 : 3; - var degreeV = yCount <= 3 ? yCount - 1 : 3; - return new NurbsSurface(m, degreeU, degreeV); - } - - /// public Interval DomainU => new Interval(this.KnotsU[0], this.KnotsU[this.KnotsU.Count - 1]); @@ -105,21 +80,63 @@ public Point3d PointAt(double u, double v) => NurbsCalculator.SurfacePoint( /// - public Vector3d NormalAt(double u, double v) => throw new System.NotImplementedException(); + public Vector3d NormalAt(double u, double v) => throw new NotImplementedException(); /// - public Plane FrameAt(double u, double v) => throw new System.NotImplementedException(); + public Plane FrameAt(double u, double v) => throw new NotImplementedException(); /// - public double DistanceTo(Point3d point) => throw new System.NotImplementedException(); + public double DistanceTo(Point3d point) => throw new NotImplementedException(); /// - public Point3d ClosestPointTo(Point3d point) => throw new System.NotImplementedException(); + public Point3d ClosestPointTo(Point3d point) => throw new NotImplementedException(); + + + /// + /// Creates a square flat surface on the XY Plane. + /// + /// Dimension interval on the X direction. + /// Dimension interval on the Y direction. + /// Number of points on the X direction. + /// Number of points on the Y direction. + /// Flat nurbs surface. + public static NurbsSurface CreateFlatSurface( + Interval xDimension, + Interval yDimension, + int xCount, + int yCount) + { + var rnd = new Random(); + var wDomain = new Interval(1, 5); + var m = new Matrix(xCount, yCount); + for (var i = 0; i < xCount; i++) + { + for (var j = 0; j < yCount; j++) + { + m[i, j] = new Point4d( + xDimension.RemapFromUnit(( double ) i / xCount), + yDimension.RemapFromUnit(( double ) j / yCount), + 0, + 1); + } + } + var degreeU = xCount <= 3 ? xCount - 1 : 3; + var degreeV = yCount <= 3 ? yCount - 1 : 3; + return new NurbsSurface(m, degreeU, degreeV); + } + + /// + /// Computes the derivatives at at S(u,v). + /// + /// U parameter to compute at. + /// V parameter to compute at. + /// Number of derivatives to compute. + /// Computed derivatives. public Matrix DerivativesAt(double u, double v, int count) => NurbsCalculator.NurbsSurfaceDerivs( this.ControlPoints.M - 1, diff --git a/src/Geometry/3D/Plane.cs b/src/Geometry/3D/Plane.cs index 44be5d2..fec1132 100644 --- a/src/Geometry/3D/Plane.cs +++ b/src/Geometry/3D/Plane.cs @@ -169,7 +169,7 @@ public void Flip() /// Coordinate for the Z axis. /// Computed point. public Point3d PointAt(double u, double v, double w) => - this.Origin + ((u * this.XAxis) + (v * this.YAxis) + (w * this.ZAxis)); + this.Origin + (u * this.XAxis + v * this.YAxis + w * this.ZAxis); /// @@ -194,7 +194,7 @@ public Point3d RemapToPlaneSpace(Point3d point) /// Point to remap. /// Point with relative coordinates to the plane. public Point3d RemapToWorldXYSpace(Point3d point) => - this.Origin + (point.X * this.XAxis) + (point.Y * this.YAxis) + (point.Z * this.ZAxis); + this.Origin + point.X * this.XAxis + point.Y * this.YAxis + point.Z * this.ZAxis; /// diff --git a/src/Geometry/3D/Point3d.cs b/src/Geometry/3D/Point3d.cs index 85a69af..862b917 100644 --- a/src/Geometry/3D/Point3d.cs +++ b/src/Geometry/3D/Point3d.cs @@ -87,6 +87,7 @@ public double DistanceTo(Point3d point) => Math.Sqrt( /// public override bool Equals(object obj) => base.Equals(obj); + /// public override int GetHashCode() => base.GetHashCode(); diff --git a/src/Geometry/3D/Primitives/Sphere.cs b/src/Geometry/3D/Primitives/Sphere.cs index 1693529..6447590 100644 --- a/src/Geometry/3D/Primitives/Sphere.cs +++ b/src/Geometry/3D/Primitives/Sphere.cs @@ -10,7 +10,7 @@ namespace Paramdigma.Core.Geometry public class Sphere : ISurface { /// - /// Initializes a new instance of given it's base plane and radius. + /// Initializes a new instance of given it's base plane and radius. /// /// /// @@ -27,7 +27,7 @@ public Sphere(Plane plane, double radius) /// - /// Initializes a new instance of around the World origin with unit radius. + /// Initializes a new instance of around the World origin with unit radius. /// public Sphere() : this(Plane.WorldXY, 1) { } diff --git a/src/Geometry/Intersect/Intersect.cs b/src/Geometry/Intersect/Intersect.cs index e5fcd8b..42e40d0 100644 --- a/src/Geometry/Intersect/Intersect.cs +++ b/src/Geometry/Intersect/Intersect.cs @@ -18,7 +18,10 @@ public static partial class Intersect3D /// The 3d plane to intersect. /// The resulting intersection point, if it exists. /// Intersection result. - public static LinePlaneIntersectionStatus LinePlane(Line line, Plane plane, out Point3d intersectionPoint) + public static LinePlaneIntersectionStatus LinePlane( + Line line, + Plane plane, + out Point3d intersectionPoint) { var u = line.EndPoint - line.StartPoint; var w = line.StartPoint - plane.Origin; @@ -135,7 +138,10 @@ public static RayFacePerimeterIntersectionStatus RayFacePerimeter( /// Second line to intersect. /// Struct containing the intersection result. /// Returns an enum containing the intersection status. - public static LineLineIntersectionStatus LineLine(Line lineA, Line lineB, out LineLineIntersectionResult result) + public static LineLineIntersectionStatus LineLine( + Line lineA, + Line lineB, + out LineLineIntersectionResult result) { var u = lineA.EndPoint - lineA.StartPoint; var v = lineB.EndPoint - lineB.StartPoint; diff --git a/src/Geometry/SpatialStructures/PointCloud.cs b/src/Geometry/SpatialStructures/PointCloud.cs index 417b76d..c6116e8 100644 --- a/src/Geometry/SpatialStructures/PointCloud.cs +++ b/src/Geometry/SpatialStructures/PointCloud.cs @@ -10,7 +10,7 @@ namespace Paramdigma.Core.SpatialSearch public class PointCloud : IList { /// - /// Constructs a new point-cloud from a list of point cloud members.. + /// Constructs a new point-cloud from a list of point cloud members.. /// /// List of point-cloud members. public PointCloud(List points) => this.Points = points; diff --git a/src/Optimization/GradientDescent.cs b/src/Optimization/GradientDescent.cs index 54a3916..4bdd106 100644 --- a/src/Optimization/GradientDescent.cs +++ b/src/Optimization/GradientDescent.cs @@ -71,6 +71,7 @@ public void Minimize(FitnessFunction function, List inputValues) } while (gLength > this.Options.Limit && iter < this.Options.MaxIterations && this.Result.Error > this.Options.ErrorThreshold); + Console.ResetColor(); } diff --git a/src/Optimization/KMeansClustering.cs b/src/Optimization/KMeansClustering.cs index 3fa221c..1958120 100644 --- a/src/Optimization/KMeansClustering.cs +++ b/src/Optimization/KMeansClustering.cs @@ -171,12 +171,12 @@ protected virtual void OnIterationCompleted(IterationCompletedEventArgs iterArgs public class IterationCompletedEventArgs : EventArgs { /// - /// Iteration number. + /// Iteration number. /// public int Iteration { get; set; } - + /// - /// Clusters for current iteration. + /// Clusters for current iteration. /// public List Clusters { get; set; } } diff --git a/src/Paramdigma.Core.csproj b/src/Paramdigma.Core.csproj index 63d6d27..dcd0135 100644 --- a/src/Paramdigma.Core.csproj +++ b/src/Paramdigma.Core.csproj @@ -4,7 +4,7 @@ Computational Geometry library for .NET - netstandard2.0 + netstandard2.1 Paramdigma Core https://paramdigma.com/Core/ https://github.com/Paramdigma/Core/blob/master/LICENSE diff --git a/src/Utility/Settings.cs b/src/Utility/Settings.cs index 64ff51e..fec2ef8 100644 --- a/src/Utility/Settings.cs +++ b/src/Utility/Settings.cs @@ -59,7 +59,8 @@ public static void Reset() using (var stream = assembly.GetManifestResourceStream("Paramdigma.Core.Data.Settings.json")) { - using (var reader = new StreamReader(stream ?? throw new InvalidOperationException("Could not get settings."))) + using (var reader = new StreamReader( + stream ?? throw new InvalidOperationException("Could not get settings."))) { var result = reader.ReadToEnd(); var json = JsonConvert.DeserializeObject(result); @@ -69,7 +70,7 @@ public static void Reset() } } } - + /// /// This struct holds the settings from the embedded json file. It is only used to reset. /// diff --git a/tests/Geometry/2D/DelaunayTests.cs b/tests/Geometry/2D/DelaunayTests.cs index 17a905c..469970b 100644 --- a/tests/Geometry/2D/DelaunayTests.cs +++ b/tests/Geometry/2D/DelaunayTests.cs @@ -26,11 +26,7 @@ public void CanComputeDelaunay() var delaunay = Delaunay.Compute( new List { - point0, - point1, - point2, - point3, - point4 + point0, point1, point2, point3, point4 }, border ) diff --git a/tests/Geometry/2D/Line2dTests.cs b/tests/Geometry/2D/Line2dTests.cs index fe2f7d8..b1a46cc 100644 --- a/tests/Geometry/2D/Line2dTests.cs +++ b/tests/Geometry/2D/Line2dTests.cs @@ -14,11 +14,10 @@ public void CanBe_Created() var line = new Line2d(ptA, ptB); var lineB = new Line2d(ptA, v); var lineC = new Line2d(ptA, v, 3); - + Assert.NotNull(line); Assert.NotNull(lineB); Assert.NotNull(lineC); - } } } \ No newline at end of file diff --git a/tests/Geometry/2D/Polyline2dTests.cs b/tests/Geometry/2D/Polyline2dTests.cs index 8dac418..3874e9f 100644 --- a/tests/Geometry/2D/Polyline2dTests.cs +++ b/tests/Geometry/2D/Polyline2dTests.cs @@ -81,7 +81,8 @@ public void Constructor_ClosedOption_AddsVertexAndSegment( [ClassData(typeof(Polyline2dUnitSquareAndSegments))] public void DefaultDomain_IsParametrizedByArcLength( Polyline2d polyline, - double expectedLength) => Assert.True(Math.Abs(polyline.Domain.End - expectedLength) < Settings.Tolerance); + double expectedLength) => Assert.True( + Math.Abs(polyline.Domain.End - expectedLength) < Settings.Tolerance); [Theory] @@ -90,7 +91,9 @@ public void Reparametrize_SetsAllSegmentsDomain(Polyline2d polyline) { polyline.Reparametrize(); - Assert.True(Math.Abs(polyline.Domain.End - polyline.Segments[^1].Domain.End) < Settings.Tolerance); + Assert.True( + Math.Abs(polyline.Domain.End - polyline.Segments[^1].Domain.End) + < Settings.Tolerance); Assert.True(Math.Abs(polyline.Domain.End - 1) < Settings.Tolerance); } diff --git a/tests/Geometry/3D/CurveBaseTests.cs b/tests/Geometry/3D/CurveBaseTests.cs index b68c862..9e39fcc 100644 --- a/tests/Geometry/3D/CurveBaseTests.cs +++ b/tests/Geometry/3D/CurveBaseTests.cs @@ -3,7 +3,7 @@ namespace Paramdigma.Core.Tests.Geometry public abstract class CurveBaseTests { public T TestCurve; - + public abstract void CanGet_Length(); public abstract void CanGet_PointAt(); diff --git a/tests/Geometry/3D/CylinderTests.cs b/tests/Geometry/3D/CylinderTests.cs index e3415fd..fdd61d2 100644 --- a/tests/Geometry/3D/CylinderTests.cs +++ b/tests/Geometry/3D/CylinderTests.cs @@ -1,3 +1,4 @@ +using System; using Paramdigma.Core.Collections; using Paramdigma.Core.Geometry; using Xunit; @@ -13,6 +14,8 @@ private void CanCompute_PointAtCylinder() var actual = cyl.PointAt(0, 0); var expected = new Point3d(1, 0, 0); Assert.Equal(actual, expected); + Assert.Throws(() => cyl.PointAt(-1, 0)); + Assert.Throws(() => cyl.PointAt(0, -1)); } @@ -34,5 +37,12 @@ public void CanCreate_FromPlaneHeightRadius() Assert.Equal(1, cyl.Radius); Assert.Equal(1, cyl.Height); } + + [Fact] + public void CannotCreate_FromInvalidData() + { + Assert.Throws(() => new Cylinder(Plane.WorldXY, -1, Interval.Unit)); + Assert.Throws(() => new Cylinder(Plane.WorldXY, 1, new Interval(0, Settings.Tolerance/2))); + } } } \ No newline at end of file diff --git a/tests/Geometry/3D/LineTests.cs b/tests/Geometry/3D/LineTests.cs index 4f5ee65..544e7b1 100644 --- a/tests/Geometry/3D/LineTests.cs +++ b/tests/Geometry/3D/LineTests.cs @@ -22,7 +22,8 @@ public override void CanGet_BiNormal() [Fact] - public override void CanGet_Length() => Assert.True(Math.Abs(this.TestLine.Length - Math.Sqrt(3)) < Settings.Tolerance); + public override void CanGet_Length() => Assert.True( + Math.Abs(this.TestLine.Length - Math.Sqrt(3)) < Settings.Tolerance); [Fact] diff --git a/tests/Geometry/3D/MeshCornerTests.cs b/tests/Geometry/3D/MeshCornerTests.cs new file mode 100644 index 0000000..86e2afe --- /dev/null +++ b/tests/Geometry/3D/MeshCornerTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using Paramdigma.Core.Geometry; +using Paramdigma.Core.HalfEdgeMesh; +using Xunit; + +namespace Paramdigma.Core.Tests.Geometry +{ + + + public class MeshCornerTests + { + + public Mesh FlatTriangle + { + get + { + var ptA = new Point3d(0, 0, 0); + var ptB = new Point3d(1, 0, 0); + var ptC = new Point3d(1, 1, 0); + var vertices = new List {ptA, ptB, ptC}; + var face = new List {0, 1, 2}; + var mesh = new Mesh(vertices, new List> {face}); + return mesh; + } + } + + + [Fact] + public void HasPropertiesAssigned() + { + FlatTriangle.Corners.ForEach( + corner => + { + Assert.NotNull(corner.Vertex); + Assert.NotNull(corner.Face); + Assert.NotNull(corner.Next); + Assert.NotNull(corner.Prev); + Assert.NotNull(corner.Index); + + }); + } + } +} \ No newline at end of file diff --git a/tests/Geometry/3D/MeshPointTests.cs b/tests/Geometry/3D/MeshPointTests.cs index d7c80f8..4e8c066 100644 --- a/tests/Geometry/3D/MeshPointTests.cs +++ b/tests/Geometry/3D/MeshPointTests.cs @@ -1,10 +1,29 @@ +using System.Collections.Generic; +using Paramdigma.Core.Geometry; using Paramdigma.Core.HalfEdgeMesh; using Xunit; namespace Paramdigma.Core.Tests.Geometry { + + public class MeshPointTests { + + public Mesh FlatTriangle + { + get + { + var ptA = new Point3d(0, 0, 0); + var ptB = new Point3d(1, 0, 0); + var ptC = new Point3d(1, 1, 0); + var vertices = new List {ptA, ptB, ptC}; + var face = new List {0, 1, 2}; + var mesh = new Mesh(vertices, new List> {face}); + return mesh; + } + } + [Fact] public void CanConstruct_FromNumbers() { @@ -15,7 +34,14 @@ public void CanConstruct_FromNumbers() Assert.Equal(0.6, pt.W); } - + [Fact] + public void CanConstruct_FromEntities() + { + + var pt = new MeshPoint(FlatTriangle.Faces[0],new Point3d(0.4,0.5,0.6)); + Assert.Equal(0, pt.FaceIndex); + Assert.NotNull(pt); + } [Fact] public void CanConvert_ToString() { diff --git a/tests/Geometry/3D/MeshTopologyTests.cs b/tests/Geometry/3D/MeshTopologyTests.cs new file mode 100644 index 0000000..2338509 --- /dev/null +++ b/tests/Geometry/3D/MeshTopologyTests.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using Paramdigma.Core.Geometry; +using Paramdigma.Core.HalfEdgeMesh; +using Xunit; + +namespace Paramdigma.Core.Tests.Geometry +{ + public class MeshTopologyTests + { + public Mesh FlatSquare + { + get + { + var ptA = new Point3d(0, 0, 0); + var ptB = new Point3d(1, 0, 0); + var ptC = new Point3d(1, 1, 0); + var ptD = new Point3d(0, 1, 0); + var vertices = new List {ptA, ptB, ptC, ptD}; + var face = new List {0, 1, 2, 3}; + var mesh = new Mesh(vertices, new List> {face}); + return mesh; + } + } + + public Mesh FlatTriangle + { + get + { + var ptA = new Point3d(0, 0, 0); + var ptB = new Point3d(1, 0, 0); + var ptC = new Point3d(1, 1, 0); + var vertices = new List {ptA, ptB, ptC}; + var face = new List {0, 1, 2}; + var mesh = new Mesh(vertices, new List> {face}); + return mesh; + } + } + + + [Fact] + public void CanCreate_MeshTopology() + { + // TODO: Improve this tests with better assertions. + var topo = new MeshTopology(FlatSquare); + + Assert.Empty(topo.FaceFace); + } + + [Fact] + public void CanConvert_ToString() + { + // TODO: Improve this tests with better assertions. + var topo = new MeshTopology(FlatSquare); + + Assert.NotNull(topo.TopologyDictToString(topo.FaceFace)); + Assert.NotNull(topo.TopologyDictToString(topo.VertexVertex)); + Assert.NotNull(topo.TopologyDictToString(topo.EdgeEdge)); + } + } +} \ No newline at end of file diff --git a/tests/Geometry/3D/NurbsCurveTests.cs b/tests/Geometry/3D/NurbsCurveTests.cs index b8bba3c..dc03a73 100644 --- a/tests/Geometry/3D/NurbsCurveTests.cs +++ b/tests/Geometry/3D/NurbsCurveTests.cs @@ -11,10 +11,10 @@ public class NurbsCurveTests { private readonly List controlPoints = new List { - new Point4d(0, 0, 0,4), - new Point4d(1, 3, 0,3.5), - new Point4d(1.4, 5, 0,2), - new Point4d(0, 7, 0,1), + new Point4d(0, 0, 0, 4), + new Point4d(1, 3, 0, 3.5), + new Point4d(1.4, 5, 0, 2), + new Point4d(0, 7, 0, 1) }; private NurbsCurve Curve => new NurbsCurve(this.controlPoints, 3); @@ -24,12 +24,11 @@ private RG.NurbsCurve RhCurve get { var rhcrv = RG.Curve.CreateControlPointCurve( - this.controlPoints.Select(pt => pt.Position.ToRhino()), - 3).ToNurbsCurve(); + this.controlPoints.Select(pt => pt.Position.ToRhino()), + 3) + .ToNurbsCurve(); for (var i = 0; i < this.controlPoints.Count; i++) - { rhcrv.Points.SetWeight(i, this.controlPoints[i].Weight); - } rhcrv.Domain = new RG.Interval(0, 1); return rhcrv.ToNurbsCurve(); } diff --git a/tests/Geometry/3D/NurbsSurfaceTests.cs b/tests/Geometry/3D/NurbsSurfaceTests.cs index 560da35..c10c442 100644 --- a/tests/Geometry/3D/NurbsSurfaceTests.cs +++ b/tests/Geometry/3D/NurbsSurfaceTests.cs @@ -1,7 +1,5 @@ -using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using Paramdigma.Core.Collections; using Paramdigma.Core.Geometry; using Paramdigma.Core.Tests.Conversions; @@ -16,12 +14,10 @@ public class NurbsSurfaceTests private readonly ITestOutputHelper testOutputHelper; - public NurbsSurfaceTests(ITestOutputHelper testOutputHelper) - { + public NurbsSurfaceTests(ITestOutputHelper testOutputHelper) => this.testOutputHelper = testOutputHelper; - } - + [Theory] [ClassData(typeof(NurbsSurfaceUnitParamData))] public void CanGet_PointAt(double u, double v) @@ -40,18 +36,18 @@ public void CanGet_PointAt(double u, double v) public void CanGet_TangentAt(double u, double v) { var surf = NurbsSurface.CreateFlatSurface(Interval.Unit, Interval.Unit, 4, 4); - var uT = surf.DerivativesAt(u, v, 1)[0,1].Unit(); - var vT = surf.DerivativesAt(u, v, 1)[1,0].Unit(); + var uT = surf.DerivativesAt(u, v, 1)[0, 1].Unit(); + var vT = surf.DerivativesAt(u, v, 1)[1, 0].Unit(); var rhSurf = surf.ToRhino(); - + var uCrv = rhSurf.IsoCurve(1, v); - uCrv.Domain = new RG.Interval(0,1); + uCrv.Domain = new RG.Interval(0, 1); var vCrv = rhSurf.IsoCurve(0, u); - vCrv.Domain = new RG.Interval(0,1); + vCrv.Domain = new RG.Interval(0, 1); var uVector = uCrv.TangentAt(u); var vVector = vCrv.TangentAt(v); - + Assert.True((uVector.ToCore() - uT).Length <= Settings.Tolerance); Assert.True((vVector.ToCore() - vT).Length <= Settings.Tolerance); } @@ -62,16 +58,14 @@ public void CanGet_TangentAt(double u, double v) public void CanGet_NormalAt(double u, double v) { var surf = NurbsSurface.CreateFlatSurface(Interval.Unit, Interval.Unit, 4, 4); - var uT = surf.DerivativesAt(u, v, 1)[0,1]; - var vT = surf.DerivativesAt(u, v, 1)[1,0]; + var uT = surf.DerivativesAt(u, v, 1)[0, 1]; + var vT = surf.DerivativesAt(u, v, 1)[1, 0]; var cross = vT.Cross(uT).Unit(); var rhSurf = surf.ToRhino(); var rhVector = rhSurf.NormalAt(u, v); rhVector.Unitize(); Assert.True((rhVector.ToCore() - cross).Length <= Settings.Tolerance); } - - } public class NurbsSurfaceUnitParamData : IEnumerable diff --git a/tests/Geometry/3D/NurbsTests.cs b/tests/Geometry/3D/NurbsTests.cs deleted file mode 100644 index c85519a..0000000 --- a/tests/Geometry/3D/NurbsTests.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using Paramdigma.Core.Collections; -using Paramdigma.Core.Geometry; -using Xunit; -using Xunit.Abstractions; - -namespace Paramdigma.Core.Tests -{ - public class NurbsTests - { - private readonly ITestOutputHelper testOutputHelper; - - - public NurbsTests(ITestOutputHelper testOutputHelper) => - this.testOutputHelper = testOutputHelper; - - - public Matrix FlatGrid(int size) - { - var m = new Matrix(size); - for (var i = 0; i < size; i++) - { - for (var j = 0; j < size; j++) - m[i, j] = new Point3d(i, j, 0); - } - - return m; - } - - - [Theory] - [InlineData(0.0, 0.0)] - public void Decasteljau2_Works(double u, double v) - { - const int n = 5; - var points = this.FlatGrid(n); - var pt = NurbsCalculator.DeCasteljau2(points, 3, 3, u, v); - - Assert.NotNull(pt); - } - - - [Fact] - public void Decasteljau1_Works() - { - var points = new List(); - for (var i = 0; i < 5; i++) - points.Add(new Point3d(i, 0, 0)); - var pt = NurbsCalculator.DeCasteljau1(points.ToArray(), points.Count - 1, 1); - Assert.NotNull(pt); - } - - - [Fact] - public void NurbsCurvePoint_Works() - { - var p0 = new Point3d(0, 0, 0); - var p1 = new Point3d(1, 3, 0); - var p2 = new Point3d(1.4, 5, 0); - var p3 = new Point3d(0, 7, 0); - var pts = new[] {p0, p1, p2, p3}; - - var u = NurbsCalculator.CreateUniformKnotVector(pts.Length, 1); - var u2 = NurbsCalculator.CreateUniformKnotVector(pts.Length, 2); - var u3 = NurbsCalculator.CreateUniformKnotVector(pts.Length, 3); - var watch = new Stopwatch(); - watch.Start(); - const int n = 100; - for (var i = 0; i <= n; i++) - { - var pt = NurbsCalculator.CurvePoint( - 3, - 1, - u, - pts, - ( double ) i / n); - var pt2 = NurbsCalculator.CurvePoint( - 3, - 2, - u2, - pts, - ( double ) i / n); - var pt3 = NurbsCalculator.CurvePoint( - 3, - 3, - u3, - pts, - ( double ) i / n); - Assert.NotNull(pt); - Assert.NotNull(pt2); - Assert.NotNull(pt3); - } - - watch.Stop(); - this.testOutputHelper.WriteLine(watch.Elapsed.ToString()); - } - - - [Fact] - public void TestKnotVector() - { - var u = NurbsCalculator.CreateUniformKnotVector(3, 1); - var u2 = NurbsCalculator.CreateUniformKnotVector(4, 2); - var u3 = NurbsCalculator.CreateUniformKnotVector(5, 3); - Assert.NotNull(u); - Assert.NotNull(u2); - Assert.NotNull(u3); - } - } -} \ No newline at end of file diff --git a/tests/Geometry/3D/PlaneTests.cs b/tests/Geometry/3D/PlaneTests.cs index 0bfb212..2158729 100644 --- a/tests/Geometry/3D/PlaneTests.cs +++ b/tests/Geometry/3D/PlaneTests.cs @@ -37,7 +37,7 @@ public void CanBe_Created() var ptB = new Point3d(0, 1, 0); var ptC = new Point3d(0, 0, 0); var planeC = new Plane(ptC, ptA, ptB); - + Assert.NotNull(plane); Assert.NotNull(planeB); Assert.NotNull(planeC); diff --git a/tests/Geometry/3D/Point3dTests.cs b/tests/Geometry/3D/Point3dTests.cs index 9113970..cad9a44 100644 --- a/tests/Geometry/3D/Point3dTests.cs +++ b/tests/Geometry/3D/Point3dTests.cs @@ -127,6 +127,7 @@ public void CanBe_Multiplied() var ptA = new Point3d(a, b, c); var ptResult = new Point3d(a * m, b * m, c * m); Assert.True(ptA * m == ptResult); + Assert.True(m * ptA == ptResult); } @@ -165,5 +166,17 @@ public void CanConvert_ToArray() Assert.True(arr.Length == 3); Assert.True(Math.Abs(arr[0] - 1) < Settings.Tolerance && arr[1] == 0 && arr[2] == 0); } + + + [Fact] + public void Can_BeCloned() + { + const double a = 3.3; + const double b = 2.2; + const double c = 4.11; + var ptA = new Point3d(a, b, c); + var ptClone = ptA.Clone(); + Assert.False(ReferenceEquals(ptA,ptClone)); + } } } \ No newline at end of file diff --git a/tests/Geometry/3D/Polyline3dTests.cs b/tests/Geometry/3D/Polyline3dTests.cs index 4d5dcfc..bffaaa9 100644 --- a/tests/Geometry/3D/Polyline3dTests.cs +++ b/tests/Geometry/3D/Polyline3dTests.cs @@ -79,7 +79,9 @@ public override void CanGet_Length() { var poly = this.GetTestPolyline(i); var length = poly.Length; - Assert.True(Math.Abs(length - i) < Settings.Tolerance, $"Length {length} is not {i}"); + Assert.True( + Math.Abs(length - i) < Settings.Tolerance, + $"Length {length} is not {i}"); } } diff --git a/tests/RhinoConversions.cs b/tests/RhinoConversions.cs index ca85b29..63f76fb 100644 --- a/tests/RhinoConversions.cs +++ b/tests/RhinoConversions.cs @@ -22,16 +22,12 @@ public static RG.Vector3d ToRhino(this Vector3d vector) => new RG.Vector3d(vector.X, vector.Y, vector.Z); - public static RG.NurbsCurve ToRhino(this NurbsCurve curve) - { + public static RG.NurbsCurve ToRhino(this NurbsCurve curve) => throw new NotImplementedException(); - } - public static NurbsCurve ToCore(this RG.NurbsCurve curve) - { + public static NurbsCurve ToCore(this RG.NurbsCurve curve) => throw new NotImplementedException(); - } public static RG.NurbsSurface ToRhino(this NurbsSurface surface) @@ -69,9 +65,7 @@ public static RG.NurbsSurface ToRhino(this NurbsSurface surface) } - public static NurbsSurface ToCore(this RG.NurbsSurface surface) - { + public static NurbsSurface ToCore(this RG.NurbsSurface surface) => throw new NotImplementedException(); - } } } \ No newline at end of file