Class ConicalSurface
- Namespace
- CADability.GeoObject
- Assembly
- CADability.dll
A conical surface which implements ISurface. The surface represents a circular or elliptical cone. The u parameter always describes a circle or ellipse, the v parameter a Line.
public class ConicalSurface : ISurfaceImpl, ISurface, IOctTreeInsertable, ISerializable, IDeserializationCallback, ISurfaceOfRevolution, IExportStep, ICone, IJsonSerialize
- Inheritance
-
ConicalSurface
- Implements
- Inherited Members
- Extension Methods
Constructors
ConicalSurface()
Empty constructor for the JSON deserialization (IJsonSerialize); the data is set by SetObjectData(IJsonReadData).
protected ConicalSurface()
ConicalSurface(GeoPoint, GeoVector, GeoPoint, GeoVector, GeoPoint, GeoVector)
Intended to create the cone which touches three planes, each given by a point on the surface and the normal there. The implementation is unfinished: it computes the apex and the semi angle but does not set up the surface, so the resulting object is not usable. Use ConicalSurface(GeoPoint, GeoVector, GeoVector, GeoVector, double, double) or FromTwoCircles(Ellipse, Ellipse) instead.
public ConicalSurface(GeoPoint p1, GeoVector n1, GeoPoint p2, GeoVector n2, GeoPoint p3, GeoVector n3)
Parameters
p1GeoPointFirst point on the surface
n1GeoVectorThe normal of the surface at
p1p2GeoPointSecond point on the surface
n2GeoVectorThe normal of the surface at
p2p3GeoPointThird point on the surface
n3GeoVectorThe normal of the surface at
p3
ConicalSurface(GeoPoint, GeoVector, GeoVector, GeoVector, double, double)
Creates a conical surface from its apex, its axes and its semi angle. The u parameter is the angle around the axis, starting at
dirx; the v parameter is the distance from the apex measured along the surface (when the directions are
normalized), positive in direction of dirz: the point at (u, v) is
apex + vsin(semiAngle)(cos(u)*dirx + sin(u)diry) + vcos(semiAngle)*dirz. When dirx and
diry have different lengths, the cross section is an ellipse.
public ConicalSurface(GeoPoint apex, GeoVector dirx, GeoVector diry, GeoVector dirz, double semiAngle, double voffset = 0)
Parameters
apexGeoPointThe apex of the cone
dirxGeoVectorThe direction in the cross section where u = 0
diryGeoVectorThe direction in the cross section where u = π/2
dirzGeoVectorThe direction of the axis; the surface is the half cone on this side of the apex
semiAngledoubleHalf of the opening angle in radians: the angle between the axis and the generating lines
voffsetdoubleThe radius of the cross section at v = 0: when not 0, the v parameter is shifted so that v = 0 lies not at the apex but at the circle with this radius. The STEP import uses it, because there a cone is given by a point on the axis and the radius at that point; the shift is removed again by MakeCanonicalForm() once the 2d curves of the faces have been adjusted
ConicalSurface(SerializationInfo, StreamingContext)
Constructor for the legacy binary deserialization (ISerializable).
protected ConicalSurface(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoThe serialized data
contextStreamingContextThe source of the deserialization
Properties
Axis
The direction of the axis, the same as ZAxis: the half cone extends from the apex in this direction.
public GeoVector Axis { get; }
Property Value
IsRuled
returns wheather the surface is linear in u or v direction
public override RuledSurfaceMode IsRuled { get; }
Property Value
IsUPeriodic
Returns true, if this surface is periodic in the u direction (e.g. a cylinder) false otherwise.
public override bool IsUPeriodic { get; }
Property Value
IsVPeriodic
Returns true, if this surface is periodic in the v direction (e.g. a torus) false otherwise.
public override bool IsVPeriodic { get; }
Property Value
Location
The apex of the cone, where the v parameter is 0 (unless a v offset was specified when importing). Read only; use Modify(ModOp) to move the surface.
public GeoPoint Location { get; }
Property Value
OpeningAngle
The full opening angle of the cone: the angle between the two opposite generating lines at u = 0 and u = π, i.e. twice the semi angle passed to the constructor.
public Angle OpeningAngle { get; }
Property Value
Oriented
Returns true, if this surface divides the space into two parts. If the surfaces is Oriented Orientation(GeoPoint) returns a valid result
public override bool Oriented { get; }
Property Value
UPeriod
Returns the u priod of this surface if it is u periodic 0.0 otherwise
public override double UPeriod { get; }
Property Value
VPeriod
Returns the v priod of this surface if it is v periodic 0.0 otherwise
public override double VPeriod { get; }
Property Value
XAxis
The direction in the cross section where u = 0, scaled by the sine of the semi angle: the surface point at (0, v) is Location + vXAxis + vZAxis.
public GeoVector XAxis { get; }
Property Value
YAxis
The direction in the cross section where u = π/2, scaled by the sine of the semi angle: the surface point at (π/2, v) is Location + vYAxis + vZAxis.
public GeoVector YAxis { get; }
Property Value
ZAxis
The direction of the axis scaled by the cosine of the semi angle: the surface point at (u, v) is Location + v*(cos(u)XAxis + sin(u)YAxis + ZAxis).
public GeoVector ZAxis { get; }
Property Value
Methods
AxisLine(double, double)
Returns the part of the axis which corresponds to the v interval [vmin, vmax] as a Line, e.g. for displaying the axis of a face on this surface: it starts at the foot point on the axis of the surface points with v = vmin and ends at the foot point of those with v = vmax.
public Line AxisLine(double vmin, double vmax)
Parameters
Returns
- Line
The line segment on the axis
Clone()
Returns an identical but independant copy of this surface
public override ISurface Clone()
Returns
CopyData(ISurface)
Copies the data of the given surface to this surface. The two surfaces are guaranteed to be of the same type. (Used after Clone() and Modify(ModOp) to restore the original values).
public override void CopyData(ISurface CopyFrom)
Parameters
CopyFromISurfacewhere to copy the data from
Derivation2At(GeoPoint2D, out GeoPoint, out GeoVector, out GeoVector, out GeoVector, out GeoVector, out GeoVector)
Returns the point, the two first derivations and the three second derivations of the surface at the provided parameter position.
public override void Derivation2At(GeoPoint2D uv, out GeoPoint location, out GeoVector du, out GeoVector dv, out GeoVector duu, out GeoVector dvv, out GeoVector duv)
Parameters
uvGeoPoint2DPoint in the parameter space
locationGeoPointResulting 3D point
duGeoVectorResulting derivation in u
dvGeoVectorResulting derivation in v
duuGeoVectordvvGeoVectorduvGeoVector
FixedU(double, double, double)
Returns a curve where the u parameter of this surface is fixed and the v parameter starts a vmin and ends at vmax
public override ICurve FixedU(double u, double vmin, double vmax)
Parameters
Returns
FixedV(double, double, double)
Returns a curve where the v parameter of this surface is fixed and the u parameter starts a umin and ends at umax
public override ICurve FixedV(double v, double umin, double umax)
Parameters
Returns
FromTwoCircles(Ellipse, Ellipse)
The two provided circles must share a common axis and must have different radii. The resulting cone passes through the provided circles. If the conditions are not met, null will be returned.
public static ConicalSurface FromTwoCircles(Ellipse c1, Ellipse c2)
Parameters
Returns
GetDualSurfaceCurves(BoundingRect, ISurface, BoundingRect, List<GeoPoint>, List<Tuple<double, double, double, double>>)
Returns intersectionCurves
public override IDualSurfaceCurve[] GetDualSurfaceCurves(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, List<GeoPoint> seeds, List<Tuple<double, double, double, double>> extremePositions)
Parameters
thisBoundsBoundingRectBounds for this surface
otherISurfaceOther surface
otherBoundsBoundingRectBounds of other surface
seedsList<GeoPoint>3d points known to lie on the intersection curves (typically the intersection points of the edges of one face with the other face), used as starting points for the intersection curves; may be null
extremePositionsList<Tuple<double, double, double, double>>Positions (u1, v1, u2, v2) where the surfaces have an extremum of their distance, as returned by GetExtremePositions(BoundingRect, ISurface, BoundingRect, out List<Tuple<double, double, double, double>>). Entries may be double.NaN. They are used to find closed intersection curves which do not cross the bounds; may be null
Returns
GetExtrema()
Returns an array of points in parametric space where there are extrema in direction of x-, y- or z-axis. The normal vector in a extremum is parallel to one of the axis and the surface has a relative maximum or minimum in this direction.
public override GeoPoint2D[] GetExtrema()
Returns
- GeoPoint2D[]
s.a.
GetExtremePositions(BoundingRect, ISurface, BoundingRect, out List<Tuple<double, double, double, double>>)
Find positions in the uv system, where the connection of the points are perpendicular on both surfaces. the resulting list extremePositions may be
only partially filled, the missing uv values may be double.NaN, because this is what we need in most cases.
public override int GetExtremePositions(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, out List<Tuple<double, double, double, double>> extremePositions)
Parameters
thisBoundsBoundingRectotherISurfaceotherBoundsBoundingRectextremePositionsList<Tuple<double, double, double, double>>
Returns
GetLineIntersection(GeoPoint, GeoVector)
Returns the intersectionpoints of this surface with the line given by the parameters. Teh returned point are in the parametric (u/v) space of this surface.
public override GeoPoint2D[] GetLineIntersection(GeoPoint startPoint, GeoVector direction)
Parameters
Returns
GetModified(ModOp)
Returns a clone of this surface modified by the given ModOp.
public override ISurface GetModified(ModOp m)
Parameters
mModOphow to modify
Returns
GetNaturalBounds(out double, out double, out double, out double)
Returns the natural bounds of the surface. The returned values may be infinite
public override void GetNaturalBounds(out double umin, out double umax, out double vmin, out double vmax)
Parameters
GetNonPeriodicSurface(ICurve[])
Implements GetNonPeriodicSurface(ICurve[])
public override ISurface GetNonPeriodicSurface(ICurve[] orientedCurves)
Parameters
orientedCurvesICurve[]3d curves describing the outline that will be used on the resulting surface
Returns
GetNormal(GeoPoint2D)
Returns the normal vector (perpendicular to the surface) at the given u/v point
public override GeoVector GetNormal(GeoPoint2D uv)
Parameters
uvGeoPoint2Dposition of normal
Returns
- GeoVector
normal vector
GetObjectData(IJsonWriteData)
Writes the data of this surface for the JSON serialization (IJsonSerialize).
public void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDataReceives the data
GetOffsetSurface(double)
Returns a surface that is "parallel" to this surface, i.e. each point on this surface corresponds a point on the returned surface that has the same (u,v) coordinates and has the 3d coordinates oft the point plus offset*Normal at this point
public override ISurface GetOffsetSurface(double offset)
Parameters
offsetdoubleOffset to this surface
Returns
- ISurface
The offset surface
GetOffsetSurface(double, out ModOp2D)
Returns the surface parallel to this surface at the distance offset (in direction of the normal) together
with the mapping of the parameter space, for surfaces whose offset is of the same type but with a different parameter system
(the offset of a ConicalSurface is a cone with a shifted apex and a shifted v parameter). The base implementation
returns null and Null; callers then fall back to GetOffsetSurface(double), which wraps this
surface in an OffsetSurface.
public override ISurface GetOffsetSurface(double offset, out ModOp2D mod)
Parameters
offsetdoubleThe distance of the offset surface, positive in direction of the normal
modModOp2DThe 2d transformation which maps u/v points of this surface to u/v points of the offset surface
Returns
- ISurface
The offset surface, or null when not implemented for this type of surface
GetPlaneIntersection(PlaneSurface, double, double, double, double, double)
Overrides GetPlaneIntersection(PlaneSurface, double, double, double, double, double) The intersection curves are clipped to the provided bounds, which may split a single intersection curve into several parts (a hyperbola for example may enter and leave the vmin/vmax bounds several times).
public override IDualSurfaceCurve[] GetPlaneIntersection(PlaneSurface pl, double umin, double umax, double vmin, double vmax, double precision)
Parameters
plPlaneSurfacethe plane to intersect with
umindoubleleft bound of the relevant part of this surface
umaxdoubleright bound of the relevant part of this surface
vmindoublelower bound of the relevant part of this surface
vmaxdoubleupper bound of the relevant part of this surface
precisiondoubleprecision for approximated curves, 0.0: use eps
Returns
- IDualSurfaceCurve[]
the intersection curves, may be empty
GetPolynomialParameters()
Returns the coefficients of the implicit equation of the surface when it is an algebraic surface of degree at most 2 (plane, sphere, cone). The result holds 10 values c for the equation c[0]*x^2 + c[1]*y^2 + c[2]*z^2 + c[3]xy + c[4]yz + c[5]xz + c[6]*x + c[7]*y + c[8]*z + c[9] = 0, which describes the points (x, y, z) of the surface. Surfaces which cannot be described this way return null. Currently not used by CADability itself; see GetImplicitPolynomial() for the form the kernel works with.
public override double[] GetPolynomialParameters()
Returns
- double[]
The 10 coefficients of the implicit equation, or null
GetProjectedCurve(ICurve, double)
Returns the projection of the given curve in 2D coordinates. Should only be used for curves that are close to the surface.
public override ICurve2D GetProjectedCurve(ICurve curve, double precision)
Parameters
curveICurvethe 3d curve to project onto this surface
precisiondoublemaximum allowed deviation of the resulting 2d curve (mapped onto the surface) from the provided curve
Returns
GetPropertyEntry(IFrame)
Gets the IPropertyEntry to display this surface in the property grid (may be null)
public override IPropertyEntry GetPropertyEntry(IFrame frame)
Parameters
frameIFrame
Returns
GetTangentCurves(GeoVector, double, double, double, double)
Returns curves where direction is perpendicular to the normal vector
public override ICurve2D[] GetTangentCurves(GeoVector direction, double umin, double umax, double vmin, double vmax)
Parameters
Returns
- ICurve2D[]
GetUSingularities()
returns the values for the u parameter where this surface is singular i.e. changing v with this u parameter fixed doesn't change the 3D point.
public override double[] GetUSingularities()
Returns
- double[]
list of u singularities
GetVSingularities()
returns the values for the v parameter where this surface is singular i.e. changing u with this v parameter fixed doesn't change the 3D point.
public override double[] GetVSingularities()
Returns
- double[]
list of v singularities
GetZMinMax(Projection, double, double, double, double, ref double, ref double)
Gets the minimum and maximumm valus for the z-coordinate of a rectangular patch (in parametric space) of this surface under a certain projection
public override void GetZMinMax(Projection p, double umin, double umax, double vmin, double vmax, ref double zMin, ref double zMax)
Parameters
pProjectionthe projection
umindoubleleft bound of the rectangular patch
umaxdoubleright bound of the rectangular patch
vmindoublebottom bound of the rectangular patch
vmaxdoubletop bound of the rectangular patch
zMindoublereturned minimum
zMaxdoublereturned maximum
HitTest(BoundingCube, out GeoPoint2D)
Overrides HitTest(BoundingCube, out GeoPoint2D): true, when the (double)
cone passes through bc. uv is then the position of a point of the cone inside the box.
In the system of the unit cone the box is a parallelepiped K and the cone is x^2 + y^2 == z^2. K is connected, so the cone passes through K exactly when K has a point inside (x^2 + y^2 <= z^2) and a point outside. A point inside exists, when a corner is inside, when an edge dips into the cone, or when the axis passes through the box: a part of the cone which is only inside a face of K is an ellipse, which surrounds the point where the axis passes through this face. A point outside exists, when a corner is outside, or when there are corners in both halves of the cone: the segment between them passes z == 0. The hit point is on the segment between such two points. The former implementation took a point of the cone which is not always inside the box, when the axis passes through it.
public override bool HitTest(BoundingCube bc, out GeoPoint2D uv)
Parameters
bcBoundingCubeuvGeoPoint2D
Returns
Intersect(BoundingRect, ISurface, BoundingRect)
Returns the intersection curves between this surface and the provided other surface. Both surfaces are bound by rectangles.
public override ICurve[] Intersect(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)
Parameters
thisBoundsBoundingRectBounds for this surface
otherISurfaceOther surface
otherBoundsBoundingRectBounds of other surface
Returns
- ICurve[]
Array of intersection curves
Intersect(ICurve, BoundingRect, out GeoPoint[], out GeoPoint2D[], out double[])
Returns the intersection of the provided curve with this surface.
The result may be empty.
public override void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds)
Parameters
curveICurveThe curve to be intersected with
uvExtentBoundingRectThe part of the parameter space of this surface in which intersection points are searched. It is also the periodic domain in which the u/v values of the intersection points are returned
ipsGeoPoint[]Resulting 3d intersection points
uvOnFacesGeoPoint2D[]u/v values of the intersection points on this surface
uOnCurve3Dsdouble[]u parameter of intersection points on the curve
IsRotated(Axis)
returns true, if the provided direction can be interpreted as a surface of rotation around the provided rotationAxis
public override bool IsRotated(Axis rotationAxis)
Parameters
rotationAxisAxisthe axis to test
Returns
Make3dCurve(ICurve2D)
Returns a 3-dimensional curve from the given 2-dimensional curve. the 2-dimensional curve is interpreted in the u/v system of the surface.
public override ICurve Make3dCurve(ICurve2D curve2d)
Parameters
curve2dICurve2Dthe base curve
Returns
- ICurve
corresponding 3-d curve
MakeCanonicalForm()
Modifies this surface into a more canonical form and returns the modification for the parametric space which reverses this modification in 2d. Curves in the parametric space of this surface will become invalid unless modified by the returned transformation.
public override ModOp2D MakeCanonicalForm()
Returns
- ModOp2D
2d modification for the parametric space
MaxDist(GeoPoint2D, GeoPoint2D, out GeoPoint2D)
Returns the maximum distance between the surface and the straight 3d line connecting the surface points at sp
and ep, i.e. the error made when the segment from sp to ep in the
parameter space is replaced by a straight line in 3d. The triangulation uses it to decide whether an edge of a triangle must be
subdivided. The base implementation only samples the distance at 1/4, 1/2 and 3/4 of the segment; the elementary surfaces
override it with exact computations.
public override double MaxDist(GeoPoint2D sp, GeoPoint2D ep, out GeoPoint2D mp)
Parameters
spGeoPoint2DStart point in the parameter space
epGeoPoint2DEnd point in the parameter space
mpGeoPoint2DThe u/v position where the maximum distance was found
Returns
- double
The maximum distance found
Modify(ModOp)
Modifies this surface with the given operation
public override void Modify(ModOp m)
Parameters
mModOphow to modif
Orientation(GeoPoint)
Returns the orientation of the provided point. The sign of the result may be used to distinguish between inside and outside.
public override double Orientation(GeoPoint p)
Parameters
pGeoPoint
Returns
PerpendicularFoot(GeoPoint)
Returns a list of perpendicular foot points of the surface. The list may be empty
public override GeoPoint2D[] PerpendicularFoot(GeoPoint fromHere)
Parameters
fromHereGeoPointSource point for the perpendicular foot
Returns
- GeoPoint2D[]
Array of foot-points, may be empty
PointAt(GeoPoint2D)
Returns the 3-dimensional point at the given u/v point
public override GeoPoint PointAt(GeoPoint2D uv)
Parameters
uvGeoPoint2Dposition
Returns
- GeoPoint
point
PositionOf(GeoPoint)
Returns the u/v position of the given point. It is assumed that the point is on the surface, if not the result is undetermined.
public override GeoPoint2D PositionOf(GeoPoint p)
Parameters
pGeoPointpoint
Returns
- GeoPoint2D
position
ReverseOrientation()
Reverses the orientation of this surface. The normal vector will point to the other side after this operation. The returned ModOp2D determins how (u,v) coordinates of the parameter space have to be transformed to define the same 3d point.
public override ModOp2D ReverseOrientation()
Returns
- ModOp2D
Transformation of the parameter space
SameGeometry(BoundingRect, ISurface, BoundingRect, double, out ModOp2D)
Returns true if this surface and the other surface are geometrically identical, i.e. describe the same surface
in 3D space. The may have a different u/v system. The returned firstToSecond contains
the ModOp to convert from the u/v system of the first surface to the second surface.
public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond)
Parameters
thisBoundsBoundingRectBounds for this surface
otherISurfaceOther surface
otherBoundsBoundingRectBounds of other surface
precisiondoubleRequired precision
firstToSecondModOp2DTransformation between different u/v systems
Returns
- bool
True if the surfaces are geometrically equal
SetObjectData(IJsonReadData)
Restores this surface from the JSON data written by GetObjectData(IJsonWriteData) (IJsonSerialize).
public void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDataThe data to read
UDirection(GeoPoint2D)
Returns the direction at the given u/v point in direction of the u-axis
public override GeoVector UDirection(GeoPoint2D uv)
Parameters
uvGeoPoint2Dposition
Returns
- GeoVector
direction
VDirection(GeoPoint2D)
Returns the direction at the given u/v point in direction of the v-axis
public override GeoVector VDirection(GeoPoint2D uv)
Parameters
uvGeoPoint2Dposition
Returns
- GeoVector
direction