Skip to content

Commit afbebd3

Browse files
author
Dominic Beger
committed
Add constructor accepting vector to Point classes
1 parent 4d0cc00 commit afbebd3

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

SharpMath/Geometry/Point.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ public Point(Point point)
4444
this[i] = point[i];
4545
}
4646

47+
/// <summary>
48+
/// Initializes a new instance of the <see cref="Point"/> class.
49+
/// </summary>
50+
/// <param name="vector">The position <see cref="Vector"/> of the <see cref="Point"/> to create.</param>
51+
public Point(Vector vector)
52+
{
53+
Dimension = vector.Dimension;
54+
_coordinateValues = new double[Dimension];
55+
for (uint i = 0; i < vector.Dimension; ++i)
56+
this[i] = vector[i];
57+
}
58+
4759
/// <summary>
4860
/// Gets the dimension of this <see cref="Point"/>.
4961
/// </summary>

SharpMath/Geometry/Point2D.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public Point2D(double x, double y) : base(x, y)
2828
public Point2D(Point2D point) : base(point)
2929
{ }
3030

31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="Point2D"/> class.
33+
/// </summary>
34+
/// <param name="vector">The position <see cref="Vector2"/> of the <see cref="Point2D"/> to create.</param>
35+
public Point2D(Vector2 vector) : base(vector)
36+
{ }
37+
3138
/// <summary>
3239
/// Gets or sets the value of the X-coordinate.
3340
/// </summary>

SharpMath/Geometry/Point3D.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public Point3D(double x, double y, double z) : base(x, y, z)
2626
public Point3D(Point3D point) : base(point)
2727
{ }
2828

29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="Point3D"/> class.
31+
/// </summary>
32+
/// <param name="vector">The position <see cref="Vector3"/> of the <see cref="Point3D"/> to create.</param>
33+
public Point3D(Vector3 vector) : base(vector)
34+
{ }
35+
2936
/// <summary>
3037
/// Gets or sets the value of the X-coordinate.
3138
/// </summary>

0 commit comments

Comments
 (0)