Class HelicalCurve
- Namespace
- CADability.GeoObject
- Assembly
- CADability.dll
A helical curve (helix, screw line) with a constant radius and a constant pitch.
The curve is defined in the local coordinate system of a Plane: the origin of that plane is a point on the axis, the normal of the plane is the direction of the axis and the x-axis of the plane is the reference direction for the angle 0. In this local system the curve is
p(a) = (radius * cos(a), radius * sin(a), pitch * a / (2*PI))
where the angle a runs from StartParameter to StartParameter + SweepParameter
while the position of the curve (as used by PointAt(double)) runs from 0 to 1. A positive
Pitch yields a right-handed helix, a negative one a left-handed helix. With a pitch of 0 the curve
degenerates to a circular arc, with a radius of 0 it degenerates to a straight line along the axis.
[JsonVersion(1)]
public class HelicalCurve : GeneralCurve, IFeedBack, ICloneable, IColorDef, ICurve, IGeoObject, ILayer, IStyle, IOctTreeInsertable, IComparable, ILineWidth, ILinePattern, ISerializable, IJsonSerialize, IExportStep
- Inheritance
-
HelicalCurve
- Implements
- Inherited Members
Constructors
HelicalCurve()
protected HelicalCurve()
HelicalCurve(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected HelicalCurve(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
Fields
Constructor
Provide a delegate here if you want your HelicalCurve derived class to be created each time CADability creates a helical curve.
public static HelicalCurve.ConstructionDelegate Constructor
Field Value
Properties
AxisDirection
The (normalized) direction of the axis.
public GeoVector AxisDirection { get; }
Property Value
Height
The signed distance which the curve advances in the direction of the axis from the start- to the endpoint.
public double Height { get; }
Property Value
IsClosed
Determines, whether the curve is closed or open.
public override bool IsClosed { get; }
Property Value
IsLeftHanded
True, when this is a left-handed helix (i.e. the Pitch is negative).
public bool IsLeftHanded { get; }
Property Value
IsSingular
Determines, whether this curve is singular, i.e. it is only a point, returns the same value for each parameter
public override bool IsSingular { get; }
Property Value
Length
Implements Length. The arc length of a helix is proportional to the swept angle, so it can be calculated exactly.
public override double Length { get; }
Property Value
Location
The point on the axis which corresponds to the angle 0 and the height 0.
public GeoPoint Location { get; }
Property Value
NumberOfTurns
The number of turns of this curve, may be fractional and negative.
public double NumberOfTurns { get; set; }
Property Value
Pitch
The advance along the axis for one full turn. Positive for a right-handed, negative for a left-handed helix.
public double Pitch { get; set; }
Property Value
Plane
The coordinate system of this helix: the origin is a point on the axis, the normal is the direction of the axis and the x-axis defines the angle 0.
public Plane Plane { get; set; }
Property Value
Radius
The distance of the curve from the axis.
public double Radius { get; set; }
Property Value
StartParameter
The angle (in radian) at position 0.0.
public double StartParameter { get; set; }
Property Value
SweepParameter
The swept angle (in radian) from position 0.0 to position 1.0. Negative values rotate clockwise (seen in the direction of the axis).
public double SweepParameter { get; set; }
Property Value
XAxis
The (normalized) reference direction for the angle 0.
public GeoVector XAxis { get; }
Property Value
Methods
Clone()
Clones this GeoObject.
public override IGeoObject Clone()
Returns
- IGeoObject
the cloned GeoObject
Construct()
The only way to create a HelicalCurve. There are no public constructors to assure that this is the only way to construct a helical curve.
public static HelicalCurve Construct()
Returns
- HelicalCurve
the newly created curve
CopyGeometry(IGeoObject)
Copies the geometrical aspects of the given GeoObject to this GeoObject. Both objects must be of the same type. The attributes are not copied.
public override void CopyGeometry(IGeoObject ToCopyFrom)
Parameters
ToCopyFromIGeoObjectGeoObject to copy from
DirectionAt(double)
Returns the direction of the curve at a specified point. The parameter position of the start-point is 0.0, the parameter position of the endpoint is 1.0. Directions of a position outside this interval may be undefined.
public override GeoVector DirectionAt(double Position)
Parameters
PositiondoublePosition on the curve
Returns
- GeoVector
The requested direction
FromAxisStartPoint(GeoPoint, GeoVector, GeoPoint, double, double)
Creates a helical curve which starts at startPoint and turns numberOfTurns
times around the given axis. See SetAxisStartPoint(GeoPoint, GeoVector, GeoPoint, double, double).
public static HelicalCurve FromAxisStartPoint(GeoPoint axisLocation, GeoVector axisDirection, GeoPoint startPoint, double pitch, double numberOfTurns)
Parameters
Returns
GetBasePoints()
Implements GetBasePoints(). The curve is subdivided into segments of at most 45°.
protected override double[] GetBasePoints()
Returns
- double[]
GetObjectData(IJsonWriteData)
Writes the data of this base class (user data, layer, style, user attributes and actuator) for the JSON serialization (IJsonSerialize). Derived classes override it, call the base implementation and add their own properties.
public override void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDatareceives the data
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 override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
GetPlanarState()
Determins the state of the curve in space. A curve may be either Planar (e.g. a cicle), NonPlanar (e.g. a polyline with vertices that dont shear a common plane) or UnderDetermined (e.g. a line defines a sheaf of planes (Ebenenbüschel))
public override PlanarState GetPlanarState()
Returns
GetPlane()
Determins the plane in which the curve resides. Throws CurveException if the curve's PlanarState is NonPlanar or UnderDetermined.
public override Plane GetPlane()
Returns
- Plane
The plane
IsInPlane(Plane)
Determines whether the curve resides in the given plane.
public override bool IsInPlane(Plane p)
Parameters
pPlaneThe plane for the test
Returns
- bool
true, when the curve resides in the plane
Modify(ModOp)
Overrides Modify(ModOp). Only similarity transformations (rigid motions, uniform scaling and mirroring) map a helix onto a helix. For other modifications the radius is taken from the scaling of the reference direction and the pitch from the scaling of the axis, which is still exact when scaling along the axis only.
public override void Modify(ModOp m)
Parameters
mModOp
ParameterToPosition(double)
Implements ParameterToPosition(double). The parameter of a helical curve is the angle in radian.
public override double ParameterToPosition(double parameter)
Parameters
parameterdouble
Returns
PointAndDerivativesAt(double, int)
Overrides PointAndDerivativesAt(double, int). All derivatives of a helix are available in closed form.
public override IReadOnlyList<GeoVector> PointAndDerivativesAt(double position, int grad)
Parameters
Returns
PointAt(double)
Returns the point of the given position. The parameter position of the start-point is 0.0, the parameter position of the endpoint is 1.0. Points of a position outside this interval may be undefined. The correlation between the parameter Position and the resulting point may be not linear.
public override GeoPoint PointAt(double Position)
Parameters
PositiondoublePosition on the curve
Returns
- GeoPoint
The requested point
PositionAtLength(double)
Implements PositionAtLength(double). The arc length is proportional to the position, so this is exact.
public override double PositionAtLength(double position)
Parameters
positiondouble
Returns
PositionOf(GeoPoint)
Returns the parametric position of the point on the curve. This function is inverse to DirectionAt(double). If the given point is not on the curve, the result is the position of a point on the curve, that is close to the given point, but not necessary of the closest point.
public override double PositionOf(GeoPoint p)
Parameters
pGeoPointPoint, for which the position is requested
Returns
- double
the requested position
PositionOf(GeoPoint, double)
Implements PositionOf(GeoPoint, double).
A helix passes the same angle once per turn, so there may be several foot points. The one closest to
prefer is returned, when several foot points have (almost) the same distance.
public override double PositionOf(GeoPoint p, double prefer)
Parameters
Returns
PositionToParameter(double)
Implements PositionToParameter(double). The parameter of a helical curve is the angle in radian.
public override double PositionToParameter(double position)
Parameters
positiondouble
Returns
Reverse()
Reverses the direction of the curve.
public override void Reverse()
SetAxisStartPoint(GeoPoint, GeoVector, GeoPoint, double, double)
Sets all defining data of this helical curve. The curve starts at startPoint and turns
numberOfTurns times around the axis given by axisLocation and
axisDirection. A negative number of turns rotates clockwise (seen in the direction of the axis).
public void SetAxisStartPoint(GeoPoint axisLocation, GeoVector axisDirection, GeoPoint startPoint, double pitch, double numberOfTurns)
Parameters
axisLocationGeoPointa point on the axis
axisDirectionGeoVectorthe direction of the axis
startPointGeoPointthe start point of the curve, its distance from the axis is the radius
pitchdoublethe advance along the axis for one full turn, negative for a left-handed helix
numberOfTurnsdoublethe number of turns, may be fractional and negative
SetHelix(Plane, double, double, double, double)
Sets all defining data of this helical curve. The origin of plane is a point on the axis,
the normal of the plane is the direction of the axis and the x-axis of the plane defines the angle 0.
public void SetHelix(Plane plane, double radius, double pitch, double startParameter, double sweepParameter)
Parameters
planePlanethe coordinate system of the helix
radiusdoublethe (constant) distance from the axis
pitchdoublethe advance along the axis for one full turn, negative for a left-handed helix
startParameterdoublethe angle (in radian) at position 0.0
sweepParameterdoublethe swept angle (in radian), negative for a clockwise rotation
SetObjectData(IJsonReadData)
Reads the data written by GetObjectData(IJsonWriteData) back from the JSON serialization. Derived classes override it, call the base implementation and read their own properties. Objects referenced by the data may still be incomplete at this time, see IJsonSerializeDone.
public override void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDataprovides the data
Split(double)
Splits the curve at the given position. The position must be in the interval 0..1 and the curve must not be closed. For closed curves Split(double, double).
public override ICurve[] Split(double Position)
Parameters
PositiondoubleWhere to split
Returns
- ICurve[]
the splitted curve(s)
TangentPosition(GeoVector)
Implements TangentPosition(GeoVector). The tangent of a helix encloses a constant angle with the axis, hence there is at most one matching angle per turn.
public override double[] TangentPosition(GeoVector direction)
Parameters
directionGeoVector
Returns
- double[]
ToBSpline(double)
Approximates this helical curve by a BSpline with the given precision. A circular helix cannot be represented exactly by a (rational) BSpline, so an approximation is needed, e.g. for the STEP export.
public BSpline ToBSpline(double precision)
Parameters
precisiondoublethe maximum deviation of the BSpline from this curve
Returns
- BSpline
the approximating BSpline
Trim(double, double)
Modifies start and endpoint of this curve. StartPos must be less than EndPos. if StartPos is less than 0.0 or EndPos greater than 1.0 this only works for lines and (circular or elliptical) arcs.
public override void Trim(double StartPos, double EndPos)
Parameters
TryPointDeriv2At(double, out GeoPoint, out GeoVector, out GeoVector)
Tries to get the point and the first and second derivative of the curve at the specified position. (0..1) Some curves do not implement the second derivative and hence will return false.
public override bool TryPointDeriv2At(double u, out GeoPoint point, out GeoVector deriv, out GeoVector deriv2)
Parameters
udoublepointGeoPointThe point at the required position
derivGeoVectorderiv2GeoVectorThe second derivative at the provided parameter
Returns
Events
Constructed
public static event HelicalCurve.ConstructedDelegate Constructed