Table of Contents

Struct GeoPoint

Namespace
CADability
Assembly
CADability.dll

A 3-dimensional point with double components. The components are directly accesible to achieve maximum speed.

note

Keep in mind that this is a value type. Passing a value type as a (non ref) parameter and changing it's value inside the invoked method leaves the original unchanged.

[JsonVersion(serializeAsStruct = true, version = 1)]
public struct GeoPoint : ISerializable, IJsonSerialize, IExportStep
Implements
Inherited Members

Constructors

GeoPoint(GeoPoint, GeoPoint)

Constructs a new GeoPoint in the middle between two other GeoPoints

public GeoPoint(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

second point

GeoPoint(GeoPoint, GeoPoint, double)

Constructs a new GeoPoint by linear interpolation between two points: (1 - ratio) * p1 + ratio * p2. A ratio of 0.0 yields p1, 1.0 yields p2, values outside the range [0, 1] extrapolate beyond the two points.

public GeoPoint(GeoPoint p1, GeoPoint p2, double ratio)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

second point

ratio double

position between the two points

GeoPoint(GeoPoint, double, double, double)

Constructs a new GeoPoint as on offset from an existing GeoPoint.

public GeoPoint(GeoPoint StartWith, double OffsetX, double OffsetY, double OffsetZ)

Parameters

StartWith GeoPoint

from here

OffsetX double

x-offset

OffsetY double

y-offset

OffsetZ double

z-offset

GeoPoint(GeoPoint2D)

Creates a GeoPoint with the z-coordinate 0.0 and x,y set to p.x,p.y

public GeoPoint(GeoPoint2D p)

Parameters

p GeoPoint2D

two dimensional point in the x/y Plane

GeoPoint(GeoPoint2D, double)

Constructs a new GeoPoint from a 2-dimensional point and a z-component.

public GeoPoint(GeoPoint2D p, double z)

Parameters

p GeoPoint2D

supplies the x- and y-component

z double

z-component

GeoPoint(params GeoPoint[])

Constructs a ne GeoPoint at the geometric middle of the provided points

public GeoPoint(params GeoPoint[] p)

Parameters

p GeoPoint[]

GeoPoint(Vector)

Constructs a new GeoPoint from a MathNet.Numerics vector with exactly three entries (x, y, z), typically the solution of a linear system. Throws an ApplicationException when the vector has a different length.

public GeoPoint(Vector d)

Parameters

d Vector

vector with the three components

GeoPoint(double, double)

Constructs a new GeoPoint with given x and y components, z-component will be 0.0

public GeoPoint(double x, double y)

Parameters

x double

x-component

y double

y-component

GeoPoint(double, double, double)

Constructs a new GeoPoint with given x, y and z components.

public GeoPoint(double x, double y, double z)

Parameters

x double

x-component

y double

y-component

z double

z-component

GeoPoint(SerializationInfo, StreamingContext)

Constructor for ISerializable

public GeoPoint(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo
context StreamingContext

Fields

x

x-component

public double x

Field Value

double

y

y-component

public double y

Field Value

double

z

z-component

public double z

Field Value

double

Properties

Invalid

returns new GeoPoint(NaN, NaN, NaN);

public static GeoPoint Invalid { get; }

Property Value

GeoPoint

IsValid

True, when all three components are ordinary numbers, i.e. neither NaN nor infinite. Invalid and points that could not be computed carry NaN, and every comparison with NaN is false, so test this property before using a point that may have failed.

public bool IsValid { get; }

Property Value

bool

this[int]

Gives access to the components by index: 0 is x, 1 is y, 2 is z. Any other index throws an IndexOutOfRangeException. Convenient for loops over the coordinates.

public double this[int index] { get; set; }

Parameters

index int

0, 1 or 2

Property Value

double

the component with that index

Origin

returns the origin, same as new GeoPoint(0.0,0.0,0.0);

public static GeoPoint Origin { get; }

Property Value

GeoPoint

Methods

Center(params GeoPoint[])

Creates a new GeoPoint at the center of the points provided in the parameter list.

public static GeoPoint Center(params GeoPoint[] p)

Parameters

p GeoPoint[]

List of points

Returns

GeoPoint

The geometric center of p

Distance(GeoPoint)

Returns the distance from this point to the given point.

public double Distance(GeoPoint To)

Parameters

To GeoPoint

target point

Returns

double

distance

Distance(GeoPoint[])

Returns the length of the polyline through the given points, i.e. the sum of the distances between consecutive points. Returns 0.0 for fewer than two points. Used e.g. to check whether the poles of a BSpline are degenerate.

public static double Distance(GeoPoint[] points)

Parameters

points GeoPoint[]

the points in order

Returns

double

sum of the distances between consecutive points

Equals(object)

Overrides object.Equals

public override bool Equals(object o)

Parameters

o object

object to compare with

Returns

bool

true if equal

GetHashCode()

Overrides object.GetHashCode()

public override int GetHashCode()

Returns

int

hashcode

GetObjectData(IJsonWriteData)

Writes the three components for the JSON serialization (IJsonSerialize). The struct is serialized inline as a plain list of values and read back by the constructor taking an IJsonReadStruct.

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

receives the values

Project(Plane, GeoPoint)

Central projection of this point onto a plane: the line through center and this point is intersected with plane, and the intersection is returned in the 2-dimensional coordinate system of the plane. Throws a PlaneException when that line is parallel to the plane and a GeoVectorException when this point coincides with center. For a perpendicular projection use Project(GeoPoint).

public GeoPoint2D Project(Plane plane, GeoPoint center)

Parameters

plane Plane

the plane to project onto

center GeoPoint

the center (eye point) of the projection

Returns

GeoPoint2D

the projected point in the coordinate system of the plane

SetObjectData(IJsonReadData)

Does nothing. Value types serialized inline are restored by the constructor taking an IJsonReadStruct; this method only exists to satisfy IJsonSerialize.

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

not used

To2D()

returns a 2-dimensional point by ommiting the z-component.

public GeoPoint2D To2D()

Returns

GeoPoint2D

ToPointF(ModOp)

Returns this point modified by ModOp m as a System.Drawing.PointF

public PointF ToPointF(ModOp m)

Parameters

m ModOp

modify by

Returns

PointF

modified point

ToString()

Overrides object.ToString()

public override string ToString()

Returns

string

x.ToString()+", "+y.ToString()+", "+z.ToString()

ToVector()

Returns the vector that points from the origin to this point

public GeoVector ToVector()

Returns

GeoVector

Operators

operator +(GeoPoint, GeoVector)

Adds a vector (offset) to a GeoPoint

public static GeoPoint operator +(GeoPoint p, GeoVector v)

Parameters

p GeoPoint

the point

v GeoVector

the vector

Returns

GeoPoint

offset point

operator &(GeoPoint, GeoPoint)

Returns the squared distance of the two points. Cheaper than the distance (the | operator) because no square root is taken; use it when distances are only compared.

public static double operator &(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

second point

Returns

double

the squared distance

operator |(GeoPoint, GeoPoint)

Returns the distance of the two points

public static double operator |(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

second point

Returns

double

the distance

operator ==(GeoPoint, GeoPoint)

Determins whether two GeoPoints are exactly equal. Use IsEqual(GeoPoint, GeoPoint) if you need more control over precision.

public static bool operator ==(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

secont point

Returns

bool

true if equal

implicit operator double[](GeoPoint)

Converts the point to an array of its components, e.g. to pass it to numerical routines.

public static implicit operator double[](GeoPoint p)

Parameters

p GeoPoint

the point

Returns

double[]

the array {x, y, z}

operator !=(GeoPoint, GeoPoint)

Determins whether two GeoPoints are not equal. Use IsEqual(GeoPoint, GeoPoint) if you need more control over precision.

public static bool operator !=(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

secont point

Returns

bool

true if not equal

operator *(Matrix, GeoPoint)

Applies a 3x3 MathNet.Numerics matrix to the point, i.e. a linear transformation without translation. The matrix must have three rows and three columns, which is only checked in debug builds. For affine transformations use ModOp.

public static GeoPoint operator *(Matrix m, GeoPoint p)

Parameters

m Matrix

the 3x3 matrix

p GeoPoint

the point

Returns

GeoPoint

the transformed point

operator -(GeoPoint, GeoPoint)

Returns the vector that points from p1 to p2.

public static GeoVector operator -(GeoPoint p1, GeoPoint p2)

Parameters

p1 GeoPoint

first point

p2 GeoPoint

secont point

Returns

GeoVector

the vector

operator -(GeoPoint, GeoVector)

Subtracts a vector (offset) from a GeoPoint

public static GeoPoint operator -(GeoPoint p, GeoVector v)

Parameters

p GeoPoint

the point

v GeoVector

the vector

Returns

GeoPoint

offset point

operator -(GeoPoint)

Negates all components, i.e. reflects the point at the origin.

public static GeoPoint operator -(GeoPoint p)

Parameters

p GeoPoint

the point

Returns

GeoPoint

the point with negated components