Table of Contents

Class SineCurve2D

Namespace
CADability.Curve2D
Assembly
CADability.dll

A 2d curve of the form y = a*sin(x - x0) + y0: the segment of the unit sine curve (u, sin(u)) for u from UStart to UStart + UDiff, transformed by FromUnit. This is the shape of a planar section of a cylinder (an ellipse) in the parameter space of the CylindricalSurface, which uses it as the exact 2d curve of such intersections instead of an approximating spline. Create one with the constructor or, from four points, with Create(GeoPoint2D, GeoPoint2D, GeoPoint2D, GeoPoint2D).

public class SineCurve2D : GeneralCurve2D, ICurve2D, IQuadTreeInsertable, ISerializable
Inheritance
SineCurve2D
Implements
Inherited Members

Constructors

SineCurve2D(double, double, ModOp2D)

public SineCurve2D(double ustart, double udiff, ModOp2D fromUnit)

Parameters

ustart double
udiff double
fromUnit ModOp2D

SineCurve2D(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected SineCurve2D(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Properties

FromUnit

The transformation which maps the unit sine curve (u, sin(u)) onto this curve.

public ModOp2D FromUnit { get; }

Property Value

ModOp2D

UDiff

The difference of the parameter u of the unit sine curve (u, sin(u)) between end and start point of this curve. Negative when the curve is reversed.

public double UDiff { get; }

Property Value

double

UStart

The parameter u of the unit sine curve (u, sin(u)) at the start point of this curve.

public double UStart { get; }

Property Value

double

Methods

Clone()

Returns an independent copy of this curve of the same type. Modifying the copy does not affect this curve.

public override ICurve2D Clone()

Returns

ICurve2D

the copy

Copy(ICurve2D)

Copies the data of the given object to this object. Both objects must be of the same type.

public override void Copy(ICurve2D toCopyFrom)

Parameters

toCopyFrom ICurve2D

Copies the data of this object

Create(GeoPoint2D, GeoPoint2D, GeoPoint2D, GeoPoint2D)

Creates the sine curve with the period 2pi, which starts at p1, ends at p4 and passes (in the least squares sense) through p2 and p3: y == asin(x-x0)+y0. This is how a planar section of a cylinder (an ellipse) looks like in the parameter system of the cylinder. Returns null, if the points cannot be fitted.

public static SineCurve2D Create(GeoPoint2D p1, GeoPoint2D p2, GeoPoint2D p3, GeoPoint2D p4)

Parameters

p1 GeoPoint2D
p2 GeoPoint2D
p3 GeoPoint2D
p4 GeoPoint2D

Returns

SineCurve2D

DirectionAt(double)

Returns the direction of the curve at the provided normalized position.

public override GeoVector2D DirectionAt(double pos)

Parameters

pos double

Returns

GeoVector2D

The direction

GetArea()

Returns the signed area swept by the line from the origin to the moving point of the curve, i.e. GetAreaFromPoint(GeoPoint2D) with the origin as reference point. For a closed curve this is the enclosed area, positive when the curve runs counterclockwise, negative when it runs clockwise.

public override double GetArea()

Returns

double

the signed area

GetInflectionPoints()

Finds the inflection points of the curve numerically (see GetInflectionPoints()): the intervals of the triangulation basis (GetTriangulationBasis(out GeoPoint2D[], out GeoVector2D[], out double[])) are scanned for sign changes of the curvature numerator x'*y'' - y'*x'', with the second derivative taken as a central difference of DirectionAt(double), and each sign change is refined by Brent's root finding. Sign changes within the noise of an almost straight curve are ignored. Curves that know their second derivative exactly override it (BSpline2D does).

public override double[] GetInflectionPoints()

Returns

double[]

the normalized parameters of the inflection points in ascending order; empty for a line or a curve without inflection points

GetModified(ModOp2D)

Returns a ICurve which is this curve modified by m. The curve can be of different type, e.g. a Circle may return an Ellpse

public override ICurve2D GetModified(ModOp2D m)

Parameters

m ModOp2D

Returns

ICurve2D

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

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

GetTriangulationBasis(out GeoPoint2D[], out GeoVector2D[], out double[])

Supplies the base points of the triangulation (see MakeTriangulation()): a list of parameters, ascending from 0.0 to 1.0, with the points and the directions of the curve at them. Between two consecutive base points the curve must be free of kinks, and it should bend to one side only, so that the triangle spanned by the two points and their tangents encloses that piece of the curve; the knots of a spline or the quadrant points of an arc are typical choices. GetInflectionPoints() and Length use the same basis to bracket their numerical work. The default implementation takes the parameters 0.0, 0.25, 0.5, 0.75 and 1.0 with the normalized DirectionAt(double).

protected override void GetTriangulationBasis(out GeoPoint2D[] points, out GeoVector2D[] directions, out double[] positions)

Parameters

points GeoPoint2D[]

the base points on the curve

directions GeoVector2D[]

the directions of the curve at the base points

positions double[]

Move(double, double)

Move the curve by the given offset

public override void Move(double x, double y)

Parameters

x double
y double

PointAt(double)

Returns the point of the curve at the provided normalized position

public override GeoPoint2D PointAt(double pos)

Parameters

pos double

Returns

GeoPoint2D

The point

PositionOf(GeoPoint2D)

Returns the position of point p on the curve: 0.0 corresponds to the StartPoint 1.0 to the EndPoint

public override double PositionOf(GeoPoint2D p)

Parameters

p GeoPoint2D

Returns

double

Reverse()

Reverses the direction of this curve

public override void Reverse()

Trim(double, double)

Returns a new curve of the same type which is the part of this curve between the two normalized parameters. The curve itself remains unchanged. Normally StartPos is less than EndPos; for a closed curve (Circle2D, Ellipse2D) reversed parameters select the part that runs across the start point of the curve, for other curves the behaviour depends on the type (a Line2D or Arc2D returns the part in reversed direction).

public override ICurve2D Trim(double StartPos, double EndPos)

Parameters

StartPos double

parameter of the start of the part

EndPos double

parameter of the end of the part

Returns

ICurve2D

the trimmed curve, or null when the result would be degenerate (e.g. an arc with zero sweep)

TryPointDeriv2At(double, out GeoPoint2D, out GeoVector2D, out GeoVector2D)

Returns the point and the first two derivatives of the curve with respect to the normalized parameter at position (see TryPointDeriv2At(double, out GeoPoint2D, out GeoVector2D, out GeoVector2D)). This base implementation only provides the point and DirectionAt(double) as first derivative, sets the second derivative to the null vector and returns false; curves that know their second derivative override it.

public override bool TryPointDeriv2At(double position, out GeoPoint2D point, out GeoVector2D deriv, out GeoVector2D deriv2)

Parameters

position double

the normalized parameter

point GeoPoint2D

the point at the parameter

deriv GeoVector2D
deriv2 GeoVector2D

the second derivative, the null vector when not available

Returns

bool

true if the second derivative is available, false otherwise