Class Point3
Defines a Vector in Euclidean space with coordinates X, Y, and Z. Referenced from https://github.com/mcneel/rhinocommon/blob/master/dotnet/opennurbs/opennurbs_point.cs
public class Point3 : IEquatable<Point3>, IComparable<Point3>, IComparable
Initializes a new point with zero valued coordinates.
public Point3()
Initializes a new point by copying coordinates from another point.
public Point3(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Initializes a new point by copying coordinates from a four-dimensional point. The first three coordinates are divided by the last one. If the W (fourth) dimension of the input point is zero, then it will be discarded.
public Point3(Point4 point)
Type | Name | Description |
---|---|---|
Point4 | point | A point. |
Initializes a new point by copying coordinates from the components of a vector.
public Point3(Vector3 vector)
Type | Name | Description |
---|---|---|
Vector3 | vector | A vector. |
Initializes a new point by defining the X, Y and Z coordinates.
public Point3(double x, double y, double z)
Type | Name | Description |
---|---|---|
System.Double | x | The value of the X (first) coordinate. |
System.Double | y | The value of the Y (second) coordinate. |
System.Double | z | The value of the Z (third) coordinate. |
Each coordinate of the point must pass the IsValidDouble(Double) test.
public bool IsValid { get; }
Type | Description |
---|---|
System.Boolean |
public double this[int i] { get; set; }
Type | Name | Description |
---|---|---|
System.Int32 | i |
Type | Description |
---|---|
System.Double |
Gets the value of a point at location 0,0,0.
public static Point3 Origin { get; }
Type | Description |
---|---|
Point3 |
Dimension of point.
public int Size { get; }
Type | Description |
---|---|
System.Int32 |
Gets the value of a point at location RhinoMath.UnsetValue,RhinoMath.UnsetValue,RhinoMath.UnsetValue.
public static Point3 Unset { get; }
Type | Description |
---|---|
Point3 |
Gets or sets the X (first) coordinate of this point.
public double X { get; set; }
Type | Description |
---|---|
System.Double |
Gets or sets the Y (second) coordinate of this point.
public double Y { get; set; }
Type | Description |
---|---|
System.Double |
Gets or sets the Z (third) coordinate of this point.
public double Z { get; set; }
Type | Description |
---|---|
System.Double |
Sums up a point and a vector, and returns a new point.
(Provided for languages that do not support operator overloading. You can use the + operator otherwise)
public static Point3 Add(Vector3 vector, Point3 point)
Type | Name | Description |
---|---|---|
Vector3 | vector | A vector. |
Point3 | point | A point. |
Type | Description |
---|---|
Point3 | A new point that results from the addition of point and vector. |
Calculate the centroid of an arbitrary collection of points
public static Point3 Centroid(IEnumerable<Point3> points)
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Point3> | points | A collection of points. |
Type | Description |
---|---|
Point3 | The centroid of the points |
public int CompareTo(Point3 other)
Type | Name | Description |
---|---|---|
Point3 | other | The other Point3 to use in comparison. |
Type | Description |
---|---|
System.Int32 | 0: if this is identical to other -1: if this.X < other.X -1: if this.X == other.X and this.Y < other.Y -1: if this.X == other.X and this.Y == other.Y and this.Z < other.Z +1: otherwise. |
Removes duplicates in the supplied set of points.
public static Point3[] CullDuplicates(IEnumerable<Point3> points, double tolerance)
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Point3> | points | A list, an array or any enumerable of Point3. |
System.Double | tolerance | The minimum distance isBetween points. Points that fall within this tolerance will be discarded. . |
Type | Description |
---|---|
Point3[] | An array of points without duplicates; or null on error. |
Calculates the distance of a point to a line.
public double DistanceTo(Line line)
Type | Name | Description |
---|---|---|
Line | line | The line from which to calculate the distance. |
Type | Description |
---|---|
System.Double | The distance. |
Computes the distance isBetween two points.
public double DistanceTo(Point3 other)
Type | Name | Description |
---|---|---|
Point3 | other | Other point for distance measurement. |
Type | Description |
---|---|
System.Double | The length of the line isBetween this and the other point; or 0 if any of the points is not valid. |
Check that all values in other are within epsilon of the values in this
public bool EpsilonEquals(Point3 other, double epsilon)
Type | Name | Description |
---|---|---|
Point3 | other | |
System.Double | epsilon |
Type | Description |
---|---|
System.Boolean | True if the two points have the same coordinates as this; otherwise false. |
Determines whether the specified Point3 has the same values as the present point.
public bool Equals(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | The specified point. |
Type | Description |
---|---|
System.Boolean | True if point has the same coordinates as this; otherwise false. |
Determines whether the specified System.Object is a Point3 and has the same values as the present point.
public override bool Equals(object obj)
Type | Name | Description |
---|---|---|
System.Object | obj | The specified object. |
Type | Description |
---|---|
System.Boolean | true if obj is a Point3 and has the same coordinates as this; otherwise false. |
Computes a hash code for the present point.
public override int GetHashCode()
Type | Description |
---|---|
System.Int32 | A non-unique integer that represents this point. |
Tests whether a point is inside, outside, or coincident with a polygon.
See https://stackoverflow.com/a/63436180
public int InPolygon(Polygon polygon)
Type | Name | Description |
---|---|---|
Polygon | polygon | The polygon to test against. |
Type | Description |
---|---|
System.Int32 | Returns -1 if point is outside the polygon, 0 if it is coincident with a polygon edge, or 1 if it is inside the polygon. |
Interpolate isBetween two points returning a new point at the given interpolation parameter.
public static Point3 Interpolate(Point3 pA, Point3 pB, double t)
Type | Name | Description |
---|---|---|
Point3 | pA | First point. |
Point3 | pB | Second point. |
System.Double | t | Interpolation parameter. If t=0 then this point is set to pA. If t=1 then this point is set to pB. Values of t in isBetween 0.0 and 1.0 result in points isBetween pA and pB. |
Type | Description |
---|---|
Point3 |
Test whether a point lies on a line.
public bool IsOnLine(Line line, double tolerance = 0.001)
Type | Name | Description |
---|---|---|
Line | line | The line to test against. |
System.Double | tolerance | Default is use 1e-6 |
Type | Description |
---|---|
System.Boolean | Returns true if point is on line. |
Test whether a point lies on a plane.
public bool IsOnPlane(Plane plane, double tolerance = 0.001)
Type | Name | Description |
---|---|---|
Plane | plane | The plane to test against. |
System.Double | tolerance | Default is use 1e-6 |
Type | Description |
---|---|
System.Boolean | Returns true if point is on plane. |
Get a point isBetween two points.
public static Point3 PointBetween(Point3 p1, Point3 p2)
Type | Name | Description |
---|---|---|
Point3 | p1 | First point. |
Point3 | p2 | Second point. |
Type | Description |
---|---|
Point3 | Point isBetween first and second point. |
Projects a point onto a plane.
public Point3 ProjectToPlan(Plane plane)
Type | Name | Description |
---|---|---|
Plane | plane | Plane to project onto |
Type | Description |
---|---|
Point3 | The point projected to plane |
Constructs the string representation for the current point.
public override string ToString()
Type | Description |
---|---|
System.String | The point representation in the form X,Y,Z. |
Transforms the point using a transformation matrix.
public Point3 Transform(TransformMatrix t)
Type | Name | Description |
---|---|---|
TransformMatrix | t | The transformation matrix. |
Type | Description |
---|---|
Point3 | The transformed point as a new instance. |
Sums two Point3 instances.
public static Point3 operator +(Point3 point1, Point3 point2)
Type | Name | Description |
---|---|---|
Point3 | point1 | A point. |
Point3 | point2 | A point. |
Type | Description |
---|---|
Point3 | A new point that results from the addition of point1 and point2. |
Sums up a point and a vector, and returns a new point.
public static Point3 operator +(Point3 point, Vector3 vector)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Vector3 | vector | A vector. |
Type | Description |
---|---|
Point3 | A new point that results from the addition of point and vector. |
Sums up a point and a vector, and returns a new point.
public static Point3 operator +(Vector3 vector, Point3 point)
Type | Name | Description |
---|---|---|
Vector3 | vector | A vector. |
Point3 | point | A point. |
Type | Description |
---|---|
Point3 | A new point that results from the addition of point and vector. |
Divides a Point3 by a number.
public static Point3 operator /(Point3 point, double t)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
System.Double | t | A number. |
Type | Description |
---|---|
Point3 | A new point that is coordinate-wise divided by t. |
Determines whether two Point3 have equal values.
public static bool operator ==(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if the coordinates of the two points are exactly equal; otherwise false. |
Determines whether the first specified point comes after (has superior sorting value than) the second point.
Coordinates evaluation priority is first X, then Y, then Z.
public static bool operator>(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if a.X is larger than b.X, or a.X == b.X and a.Y is larger than b.Y, or a.X == b.X and a.Y == b.Y and a.Z is larger than b.Z; otherwise, false. |
Determines whether the first specified point comes after (has superior sorting value than) the second point, or it is equal to it.
Coordinates evaluation priority is first X, then Y, then Z.
public static bool operator >=(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if a.X is larger than b.X, or a.X == b.X and a.Y is larger than b.Y, or a.X == b.X and a.Y == b.Y and a.Z >= b.Z; otherwise, false. |
Converts a point in a control point, without needing casting.
public static implicit operator Point4(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | The point. |
Type | Description |
---|---|
Point4 | The control point. |
Converts a point in a vector, without needing casting.
public static implicit operator Vector(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Type | Description |
---|---|
Vector | The resulting Vector. |
Converts a point in a vector, without needing casting.
public static implicit operator Vector3(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Type | Description |
---|---|
Vector3 | The resulting vector3. |
Determines whether two Point3 have different values.
public static bool operator !=(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if the two points differ in any coordinate; false otherwise. |
Determines whether the first specified point comes before (has inferior sorting value than) the second point.
Coordinates evaluation priority is first X, then Y, then Z.
public static bool operator <(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if a.X is smaller than b.X, or a.X == b.X and a.Y is smaller than b.Y, or a.X == b.X and a.Y == b.Y and a.Z is smaller than b.Z; otherwise, false. |
Determines whether the first specified point comes before (has inferior sorting value than) the second point, or it is equal to it.
Coordinates evaluation priority is first X, then Y, then Z.
public static bool operator <=(Point3 a, Point3 b)
Type | Name | Description |
---|---|---|
Point3 | a | The first point. |
Point3 | b | The second point. |
Type | Description |
---|---|
System.Boolean | true if a.X is smaller than b.X, or a.X == b.X and a.Y is smaller than b.Y, or a.X == b.X and a.Y == b.Y and a.Z <= b.Z; otherwise, false. |
Multiplies a Point3 by a number.
public static Point3 operator *(Point3 point, double t)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
System.Double | t | A number. |
Type | Description |
---|---|
Point3 | A new point that is coordinate-wise multiplied by t. |
Multiplies a Point3 by a number.
public static Point3 operator *(double t, Point3 point)
Type | Name | Description |
---|---|---|
System.Double | t | A number. |
Point3 | point | A point. |
Type | Description |
---|---|
Point3 | A new point that is coordinate-wise multiplied by t. |
Subtracts a point from another point.
public static Vector3 operator -(Point3 point1, Point3 point2)
Type | Name | Description |
---|---|---|
Point3 | point1 | A point. |
Point3 | point2 | Another point. |
Type | Description |
---|---|
Vector3 | A new vector that is the difference of point minus vector. |
Subtracts a vector from a point.
public static Point3 operator -(Point3 point, Vector3 vector)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Vector3 | vector | A vector. |
Type | Description |
---|---|
Point3 | A new point that is the difference of point minus vector. |
Computes the additive inverse of all coordinates in the point, and returns the new point.
public static Point3 operator -(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | A point. |
Type | Description |
---|---|
Point3 | A point value that, when summed with the point input, yields the Origin. |
int IComparable.CompareTo(object obj)
Type | Name | Description |
---|---|---|
System.Object | obj |
Type | Description |
---|---|
System.Int32 |