Struct CoordSys
- Namespace
- CADability
- Assembly
- CADability.dll
normalized, right handed coordinate system
[JsonVersion(serializeAsStruct = true, version = 1)]
public struct CoordSys : ISerializable, IJsonSerialize
- Implements
- Inherited Members
Constructors
CoordSys(GeoPoint, GeoVector, GeoVector)
Creates a normalized, right handed coordinate system with the given origin and axes. DirectionX
is kept as the direction of the x-axis, the normal is the cross product of the two directions, and the y-axis is
recomputed perpendicular to the x-axis and the normal; all three are normalized, so the given vectors need not be
unit vectors or exactly perpendicular. Throws a CoordSysException if one of the directions is the
nullvector or both are parallel.
public CoordSys(GeoPoint Location, GeoVector DirectionX, GeoVector DirectionY)
Parameters
LocationGeoPointthe origin
DirectionXGeoVectordirection of the x-axis
DirectionYGeoVectordirection of the y-axis, adapted to be perpendicular to the x-axis
CoordSys(IJsonReadStruct)
Constructor for the JSON deserialization (IJsonSerialize): reads the origin, the x-direction and the y-direction in the order GetObjectData(IJsonWriteData) wrote them and recomputes the normal. It is found by reflection, there is no need to call it directly.
public CoordSys(IJsonReadStruct data)
Parameters
dataIJsonReadStructsupplies the values
Fields
StandardCoordSys
The global coordinate system: origin (0, 0, 0), x-axis (1, 0, 0), y-axis (0, 1, 0) and hence the normal (0, 0, 1). This is a static field rather than a property for speed; do not assign to it.
public static CoordSys StandardCoordSys
Field Value
Properties
DirectionX
The unit vector of the x-axis in global coordinates. Read-only; the orientation is set by the constructor and changed with Modify(ModOp) or Reverse().
public GeoVector DirectionX { get; }
Property Value
DirectionY
The unit vector of the y-axis in global coordinates, perpendicular to DirectionX. Read-only; the orientation is set by the constructor and changed with Modify(ModOp) or Reverse().
public GeoVector DirectionY { get; }
Property Value
GlobalToLocal
The transformation from global coordinates into the coordinates of this system, the inverse of LocalToGlobal. It is computed on first access and cached until the system changes.
public ModOp GlobalToLocal { get; }
Property Value
LocalToGlobal
The transformation from the coordinates of this system into global coordinates: it maps the origin to Location and the unit vectors of the axes to DirectionX, DirectionY and Normal. It is computed on first access and cached until the system changes.
public ModOp LocalToGlobal { get; }
Property Value
Location
The origin of the coordinate system in global coordinates. Setting it moves the system without changing its orientation and discards the cached transformations. CoordSys is a value type, so setting it affects only this copy.
public GeoPoint Location { get; set; }
Property Value
Normal
The unit vector of the z-axis in global coordinates, the cross product of DirectionX and DirectionY (the system is right handed). Read-only.
public GeoVector Normal { get; }
Property Value
Methods
GetObjectData(IJsonWriteData)
Writes the origin, the x-direction and the y-direction for the JSON serialization (IJsonSerialize). The normal and the cached transformations are not stored, they are recomputed when the struct is read back by the constructor taking an IJsonReadStruct.
public void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDatareceives 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
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
GetProjection()
Returns a parallel Projection that looks against the Normal onto the x/y plane of this system, with the x- and y-axes of this system as the horizontal and vertical directions. Used e.g. to compute the 2-dimensional extent of objects in the plane of this system.
public Projection GetProjection()
Returns
- Projection
the projection onto this coordinate system
Modify(ModOp)
Transforms this coordinate system by the given modification: the origin, the x-direction and the normal are
transformed, the directions are normalized and the y-direction is recomputed from them, so the system stays
normalized and right handed even if m contains scaling or a reflection (in the latter case the
y-direction is the opposite of the transformed old y-direction). The cached transformations are discarded.
public void Modify(ModOp m)
Parameters
mModOpthe modification to apply
Reverse()
Reverses the x-direction and the normal, keeping the origin and the y-direction. The result is this system rotated by 180 degrees about its y-axis, still right handed, with the opposite normal. The cached transformations are discarded.
public void Reverse()
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
dataIJsonReadDatanot used