Table of Contents

Struct Axis

Namespace
CADability
Assembly
CADability.dll

An axis given by a location and a direction. There is no orientation for an x-direction or y-direction. If you need that use CoordSys 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 Axis : ISerializable, IJsonSerialize
Implements
Inherited Members

Constructors

Axis(GeoPoint, GeoPoint)

Creates a new axis from two points

public Axis(GeoPoint StartPoint, GeoPoint EndPoint)

Parameters

StartPoint GeoPoint

startpoint

EndPoint GeoPoint

direction point

Axis(GeoPoint, GeoVector)

Creates a new axis from a location and a direction

public Axis(GeoPoint location, GeoVector direction)

Parameters

location GeoPoint

location

direction GeoVector

direction

Axis(IJsonReadStruct)

Constructor for the JSON deserialization (IJsonSerialize): reads the location and the direction in the order GetObjectData(IJsonWriteData) wrote them. It is found by reflection, there is no need to call it directly.

public Axis(IJsonReadStruct data)

Parameters

data IJsonReadStruct

supplies the values

Axis(SerializationInfo, StreamingContext)

Constructor required by deserialization

public Axis(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Fields

Direction

The direction of the axis

public GeoVector Direction

Field Value

GeoVector

Location

An arbitrary location of the axis

public GeoPoint Location

Field Value

GeoPoint

Properties

InvalidAxis

An axis marked as invalid: its Location is Invalid and its Direction the nullvector. Returned by methods that could not determine an axis; test with IsValid.

public static Axis InvalidAxis { get; }

Property Value

Axis

IsValid

True, when the Location is a valid point (see IsValid), false for InvalidAxis. The direction is not checked.

public bool IsValid { get; }

Property Value

bool

Methods

Clip(BoundingCube)

Returns the part of this infinite axis inside the given cube as a Line object, e.g. to display the axis of a cylinder within the extent of a model. If the axis does not pass through the cube, the returned line is degenerate (both points at the origin).

public Line Clip(BoundingCube ext)

Parameters

ext BoundingCube

the cube to clip with

Returns

Line

the clipped axis as a line

Distance(GeoPoint)

Returns the perpendicular distance of the point to the infinite line of this axis. The result is never negative. If the direction is the nullvector, the distance to Location is returned.

public double Distance(GeoPoint p)

Parameters

p GeoPoint

the point

Returns

double

the distance

GetObjectData(IJsonWriteData)

Writes the location and the direction 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

GetObjectData(SerializationInfo, StreamingContext)

Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.

public void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

SameGeometry(Axis)

Determines whether the other axis describes the same infinite line: the directions are parallel within epsa (opposite orientation counts as parallel) and the location of other lies on this axis within eps. See also SameAxis(Axis, Axis).

public bool SameGeometry(Axis other)

Parameters

other Axis

the axis to compare with

Returns

bool

true if both axes are geometrically the same line

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