Purpose:
|
Defines an ellipse.
|
|
Derivation:
|
ellipse : curve : ACIS_OBJECT : -
|
|
SAT Identifier:
|
"ellipse"
|
|
Filename:
|
kern/kernel/kerngeom/curve/elldef.hxx
|
|
Description:
|
The ellipse class represents circles and ellipses on any plane. An ellipse is defined by a center point, a unit vector normal to the plane of the ellipse, a vector defining the major axis of the ellipse (including the magnitude of the major axis), and the radius ratio of the minor axis length to the major axis length. Currently, the length of the major axis should be greater than
SPAresfit. In a circle, the radius ratio is exactly 1.0. The direction of the ellipse is defined by the right hand rule using the normal vector. Direction is important when defining an edge supported by this geometry.
|
|
|
An ellipse is a closed curve that has a period 2*pi and an interval range of [-pi,
pi]. It is parameterized by:
|
|
|
point = center +
|
|
|
M cos(t - offset) +
|
|
|
N sin(t - offset);
|
|
|
where
M and
N are the major and minor axes respectively. The offset is stored explicitly, and is present to allow future addition of an isometric scaling that does not transform the axes into those of the transformed ellipse.
|
|
|
|
|
|
|
|
References:
|
by KERN
|
BDY_GEOM_CIRCLE, ELLIPSE, cone
|
|
BASE
|
SPAparameter, SPAposition, SPAunit_vector, SPAvector
|
|
Data:
|
public SPAparameter param_off;
|
|
The parameter offset is the parameter value of the point at the end of the major axis. It is stored to allow the parameterization to remain unchanged under transformation, including shear.
|
|
|
public SPAposition centre;
|
|
Center point of ellipse.
|
|
|
public double radius_ratio;
|
|
Ratio between length of minor axis and major axis. Must be positive and less than or equal to 1. Ratio of 0 is used to indicate "uninitialized". Ratio of 1 is a circle.
|
|
|
public SPAunit_vector normal;
|
|
Normal to the plane of ellipse.
|
|
|
public SPAvector major_axis;
|
|
Vector giving length and direction of major axis.
|
|
Constructor:
|
public: ellipse::ellipse
();
|
|
|
C++ allocation constructor requests memory for this object but does not populate it.
|
|
|
|
|
|
|
public: ellipse::ellipse
(
|
|
|
ellipse const&
|
// ellipse name
|
|
|
);
|
|
|
C++ copy constructor requests memory for this object and populates it with the data from the object supplied as an argument.
|
|
|
|
|
|
|
public: ellipse::ellipse
(
|
|
|
SPAposition const&,
|
// center
|
|
|
SPAunit_vector const&,
|
// normal
|
|
|
SPAvector const&,
|
// major axis
|
|
|
double,
|
// radius ratio
|
|
|
double
|
// param_off
|
|
|
|
= 0.0
|
|
|
);
|
|
|
C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
|
|
|
Constructs an ellipse from its center, normal, radius vector and radius ratio, with an optional parameter offset.
|
|
|
|
|
Destructor:
|
public: ellipse::~ellipse
();
|
|
|
C++ destructor, deleting an
ellipse.
|
|
|
|
Methods:
|
public: virtual int ellipse::accurate_derivs
(
|
|
|
SPAinterval const&
|
|
// portion of a curve
|
|
|
|
= * (SPAinterval*) NULL_REF
|
|
|
) const;
|
|
|
Returns the number of derivatives that the
evaluate function can find accurately (and fairly directly), rather than by finite differencing, over the given portion of the curve. If there is no limit to the number of accurate derivatives, returns the value
ALL_CURVE_DERIVATIVES.
|
|
|
|
|
|
|
public: SPAbox ellipse::bound
(
|
|
|
double start,
|
|
// start param value
|
|
|
double end,
|
|
// end param value
|
|
|
SPAtransf const& t
|
|
// Transformation
|
|
|
|
= * (SPAtransf* ) NULL_REF
|
|
|
) const;
|
|
|
Retained temporarily for historical reasons.
|
|
|
|
|
|
|
public: virtual SPAbox ellipse::bound
(
|
|
|
SPAbox const&,
|
|
// region of interest
|
|
|
SPAtransf const&
|
|
// transformation
|
|
|
|
= * (SPAtransf* ) NULL_REF
|
|
|
) const;
|
|
|
Returns a bounding box around the portion of the ellipse inside a given box. The resulting bound is not necessarily the minimal one.
|
|
|
|
|
|
|
public: virtual SPAbox ellipse::bound
(
|
|
|
SPAinterval const&,
|
|
// given range
|
|
|
SPAtransf const&
|
|
// transformation
|
|
|
|
= * (SPAtransf* ) NULL_REF
|
|
|
) const;
|
|
|
Finds box around an ellipse or portion thereof bounded by parameter values (in increasing order). The resulting box is not necessarily the minimal one.
|
|
|
|
|
|
|
public: virtual SPAbox ellipse::bound
(
|
|
|
SPAposition const&,
|
|
// given range
|
|
|
SPAposition const&,
|
|
// second position
|
|
|
SPAtransf const&
|
|
// transformation
|
|
|
|
= * (SPAtransf* ) NULL_REF
|
|
|
) const;
|
|
|
Finds box around an ellipse or portion thereof bounded by points on the curve, increasing in parameter value. The points lie on the curve as supplied, not as transformed. The resulting box is not necessarily be the minimal one.
|
|
|
|
|
|
|
public: virtual logical ellipse::closed
() const;
|
|
|
Indicates whether a curve is closed, that is joins itself (smoothly or not) at the ends of its principal parameter range. This function should always return
TRUE if
periodic does.
|
|
|
|
|
|
|
public: virtual void ellipse::debug
(
|
|
|
char const*,
|
// leader
|
|
|
FILE*
|
// file pointer
|
|
|
|
= debug_file_ptr
|
|
|
) const;
|
|
|
Output details of the ellipse for inspection.
|
|
|
|
|
|
|
public: virtual curve* ellipse::deep_copy
(
|
|
|
pointer_map* pm
|
// list of items within
|
|
|
|
= NULL
|
// the entity that are
|
|
|
|
|
// already deep copied
|
|
|
) const;
|
|
|
Creates a copy of an item that does not share any data with the original. Allocates new storage for all member data and any pointers. Returns a pointer to the copied item.
|
|
|
|
|
|
|
public: virtual curve_boundcyl
|
|
|
ellipse::enclosing_cylinder (
|
|
|
const SPAinterval&
|
|
// interval
|
|
|
|
= * (SPAinterval*) NULL_REF
|
|
|
) const;
|
|
|
Returns a cylinder that encloses the portion of the curve bounded by the interval.
|
|
|
|
|
|
|
public: virtual void ellipse::eval
(
|
|
|
double,
|
|
// parameter value
|
|
|
SPAposition&,
|
|
// position
|
|
|
SPAvector&
|
|
// first derivative
|
|
|
|
= * (SPAvector* ) NULL_REF,
|
|
|
SPAvector&
|
|
// second derivative
|
|
|
|
= * (SPAvector* ) NULL_REF,
|
|
|
logical
|
|
// repeat
|
|
|
|
= FALSE,
|
|
|
logical
|
|
// logical
|
|
|
|
= FALSE
|
|
|
) const;
|
|
|
Evaluates a curve at a given parameter value, giving position, and first and second derivatives (all optionally).
|
|
|
The first logical argument, if
TRUE, is a guarantee from the calling code that the most recent call to any curve or surface member function was in fact to this routine for the same curve as the current call. It allows an implementation to cache useful intermediate results to speed up repeated evaluations, but must be used with extreme care.
|
|
|
The second logical argument may be set
TRUE if an approximate return value is acceptable. Here
approximate is not very well-defined, but may be assumed to be sufficient for visual inspection of the curve.
|
|
|
|
|
|
|
public: virtual int ellipse::evaluate
(
|
|
|
double,
|
|
// parameter value
|
|
|
SPAposition&,
|
|
// point on curve at
|
|
|
|
|
|
// given parameter
|
|
|
SPAvector**
|
|
// ptr array to
|
|
|
|
= NULL,
|
|
// derivative
|
|
|
|
|
|
// vectors, size nd,
|
|
|
|
|
|
// Any ptrs may be
|
|
|
|
|
|
// NULL ==> the
|
|
|
|
|
|
// corresponding
|
|
|
|
|
|
// derivative won't
|
|
|
|
|
|
// be returned
|
|
|
int
|
|
|
// number of
|
|
|
|
= 0,
|
|
// derivatives
|
|
|
evaluate_curve_side
|
|
// the evaluation
|
|
|
|
= evaluate_curve_unknown
|
// location
|
|
|
) const;
|
|
|
Calculates derivatives, of any order up to the number requested, and stores them in vectors provided by the user. This function returns the number it was able to calculate; this is equal to the number requested in all but the most exceptional circumstances. A certain number are evaluated directly and (more or less) accurately; higher derivatives will be automatically calculated by finite differencing; the accuracy of these decreases with the order of the derivative, as the cost increases.
|
|
|
|
|
|
|
public: virtual curve_extremum*
|
|
|
ellipse::find_extrema (
|
|
|
SPAunit_vector const&
|
// direction
|
|
|
) const;
|
|
|
Finds the extrema of an ellipse in a given direction.
|
|
|
|
|
|
|
public: double ellipse::GetMajorAxisLength
() const;
|
|
|
This method returns the length of major axis.
|
|
|
|
|
|
|
public: int ellipse::high_curvature
(
|
|
|
double k,
|
// maximum curvature
|
|
|
SPAinterval*& spans
|
// interval list
|
|
|
) const;
|
|
|
Finds regions of high curvature of the curve. This method stores an array of intervals in spans argument over which the curvature exceeds k. It returns the number of intervals stored.
|
|
|
|
|
|
|
public: law* ellipse::law_form
();
|
|
|
Returns a pointer to the law form that is part of the ellipse definition.
|
|
|
|
|
|
|
public: virtual double ellipse::length
(
|
|
|
double,
|
// first parameter
|
|
|
double
|
// second parameter
|
|
|
) const;
|
|
|
Arc length. Returns the algebraic distance along the curve between the given parameters, the sign being positive if the parameter values are given in increasing order, and negative if they are in decreasing order.
|
|
|
The result is undefined if either parameter value is outside the parameter range of a bounded curve. For a periodic curve the parameters are not reduced to the principal range, and so the portion of the curve evaluated may include several complete circuits. This function is therefore always a monotonically increasing function of its second argument if the first is held constant, and a decreasing function of its first argument if the second is held constant.
|
|
|
|
|
|
|
public: virtual double ellipse::length_param
(
|
|
|
double,
|
// datum parameter
|
|
|
double
|
// arc length
|
|
|
) const;
|
|
|
The inverse of the length function returns the parameter value of the point on the curve at the given algebraic arc length from that defined by the datum parameter.
|
|
|
The result is not defined for a bounded nonperiodic curve if the datum parameter is outside the parameter range, or if the length is outside the range bounded by the values for the ends of the parameter range.
|
|
|
|
|
|
|
public: virtual curve* ellipse::make_copy
() const;
|
|
|
Make a copy of this ellipse on the heap, and return a pointer to it.
|
|
|
|
|
|
|
public: virtual curve& ellipse::negate
();
|
|
|
Negates this ellipse; i.e., negate the normal.
|
|
|
|
|
|
|
public: virtual curve& ellipse::operator*=
(
|
|
|
SPAtransf const&
|
// transformation
|
|
|
);
|
|
|
Transforms this ellipse by the given
SPAtransf, in place.
|
|
|
|
|
|
|
public: ellipse ellipse::operator-
() const;
|
|
|
Returns an ellipse with the opposite sense from this one.
|
|
|
|
|
|
|
public: virtual logical ellipse::operator==
(
|
|
|
curve const&
|
// curve name
|
|
|
) const;
|
|
|
Test two curves for equality. This test is not guaranteed to say
equal for effectively equal curves, but is guaranteed to say
not equal if the curves are, in fact, not equal.
|
|
|
|
|
|
|
public: virtual double ellipse::param
(
|
|
|
SPAposition const&,
|
|
|
// position name
|
|
|
SPAparameter const&
|
|
|
// param curve
|
|
|
|
= * (SPAparameter* ) NULL_REF
|
|
|
) const;
|
|
|
Finds the parameter value at the given point on the ellipse. Follow the same procedure as for point_direction if the point is not on the ellipse.
|
|
|
|
|
|
|
public: virtual double
|
|
|
ellipse::param_period () const;
|
|
|
Returns the period of the curve parameter.
|
|
|
|
|
|
|
public: virtual SPAinterval ellipse::param_range
(
|
|
|
SPAbox const&
|
// bounding box
|
|
|
|
= * (SPAbox* ) NULL_REF
|
|
|
) const;
|
|
|
Returns the parameter range of the ellipse.
|
|
|
|
|
|
|
public: virtual logical ellipse::periodic
() const;
|
|
|
Indicates whether a curve is periodic, i.e., joins itself smoothly at the ends of its principal parameter range, so that edges may span the seam.
|
|
|
|
|
|
|
public: virtual SPAvector ellipse::point_curvature
(
|
|
|
SPAposition const&,
|
|
|
// position
|
|
|
SPAparameter const&
|
|
|
// parameter
|
|
|
|
= * (SPAparameter* ) NULL_REF
|
|
|
) const;
|
|
|
Finds the curvature on an ellipse at the given point on the curve. If the point is not on the ellipse, the same procedure as for
point_direction is followed.
|
|
|
|
|
|
|
public: virtual SPAunit_vector
|
|
|
ellipse::point_direction (
|
|
|
SPAposition const&,
|
|
|
// position
|
|
|
SPAparameter const&
|
|
|
// parameter
|
|
|
|
= * (SPAparameter* ) NULL_REF
|
|
|
) const;
|
|
|
Finds the tangent to an ellipse at the given point on the curve. If the point is not on the ellipse, a useful value is returned. In effect, the half-plane bounded by the axis of the ellipse that contains the given point is constructed. The the curvature of the curve where it intersects this half plane is returned. If the point is on the axis, so a half plane cannot be constructed, a zero curvature vector is returned.
|
|
|
|
|
|
|
public: virtual void ellipse::point_perp
(
|
|
|
SPAposition const&,
|
|
|
// point
|
|
|
SPAposition&,
|
|
|
// foot
|
|
|
SPAunit_vector&,
|
|
|
// direction
|
|
|
|
|
|
|
// vector
|
|
|
SPAvector&,
|
|
|
// curvature
|
|
|
SPAparameter const&
|
|
|
// param guess
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
SPAparameter&
|
|
|
// actual param
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
logical f_weak
|
|
|
// weak flag
|
|
|
|
= FALSE
|
|
|
) const;
|
|
|
Finds the foot of the perpendicular from the given point to the curve, and tangent to the curve at that point, and its parameter value. If an input parameter value is supplied (as argument 5), the perpendicular found is the one nearest to the supplied parameter position, otherwise it is the one that the curve is nearest to the given point. Any of the return value arguments may be a
NULL reference, in which case it is ignored.
|
|
|
|
|
|
|
public: void ellipse::point_perp
(
|
|
|
SPAposition const& pos,
|
|
|
// point
|
|
|
SPAposition& foot,
|
|
|
// foot
|
|
|
SPAparameter const& guess
|
|
// param guess
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
SPAparameter& actual
|
|
|
// actual param
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
logical f_weak
|
|
|
// weak flag
|
|
|
|
= FALSE
|
|
|
) const;
|
|
|
Find the foot of the perpendicular from the given point to the curve, as well as the curve direction and parameter. If an approximate parameter is given, the perpendicular is the one nearest to that parameter value, otherwise it is nearest to the given point.
|
|
|
|
|
|
|
public: void ellipse::point_perp
(
|
|
|
SPAposition const& pos,
|
|
|
// point
|
|
|
SPAposition& foot,
|
|
|
// foot
|
|
|
SPAunit_vector& foot_dt,
|
|
|
// direction
|
|
|
SPAparameter const& guess
|
|
// param guess
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
SPAparameter& actual
|
|
|
// actual param
|
|
|
|
= * (SPAparameter* )NULL_REF,
|
|
|
logical f_weak
|
|
|
// weak flag
|
|
|
|
= FALSE
|
|
|
) const;
|
|
|
Finds the foot of the perpendicular from the given point to the curve, and tangent to the curve at that point, and its parameter value. If an input parameter value is supplied (as argument 5), the perpendicular found is the one nearest to the supplied parameter position, otherwise it is the one that the curve is nearest to the given point. Any of the return value arguments may be a
NULL reference, in which case it is ignored.
|
|
|
|
|
|
|
public: void ellipse::restore_data
();
|
|
|
Restore the data for a
ellipse from a save file.
|
|
|
Switching, for the derived class save, goes through the normal virtual function mechanism. Until restore is invoked there is not an object of the right class. Instead, we switch on a table defined by static instances of the
restore_su_def class, to invoke a simple friend function that constructs an object of the right (derived) type.
|
|
|
Then it can call the appropriate member function to do the actual work. The
save_data and
restore_data function for each class is called in circumstances when the type of surface is known and there is one available to be filled in.
|
|
|
read_position
|
Position of the center of the ellipse.
|
|
read_unit_vector
|
Unit vector that is normal to plane of the ellipse.
|
|
read_vector
|
major axis of the ellipse.
|
|
read_real
|
Ratio of the radii.
|
|
curve::restore_data
|
|
Restore the underlying curve of the ellipse.
|
|
|
|
|
|
|
public: virtual void ellipse::save
() const;
|
|
|
Saves the curve type or id, then calls
save_data.
|
|
|
|
|
|
|
public: void ellipse::save_data
() const;
|
|
|
Saves the data for a
ellipse to a save file.
|
|
|
|
|
|
|
public: virtual curve_tancone ellipse::tangent_cone
(
|
|
|
SPAinterval const&,
|
|
// given range
|
|
|
logical
|
|
// approximation ok
|
|
|
|
= FALSE,
|
|
|
SPAtransf const&
|
|
// transformation
|
|
|
|
= * (SPAtransf* ) NULL_REF
|
|
|
) const;
|
|
|
Returns a cone bounding the tangent direction of the curve. The cone is deemed to have its apex at the origin, and have a given axis direction and (positive) half-angle. If the logical argument is
TRUE, then a quick approximation may be found. The approximate result may lie wholly within or wholly outside the guaranteed bound (obtained with a
FALSE argument), but may not cross from inside to outside. Flags in the returned object indicate whether the cone is in fact the best available, and if not whether this result is inside or outside the best cone.
|
|
|
|
|
|
|
public: virtual logical ellipse::test_point_tol
(
|
|
|
SPAposition const&,
|
|
|
// point
|
|
|
double
|
|
|
// tolerance
|
|
|
|
= 0,
|
|
|
SPAparameter const&
|
|
|
// param guess
|
|
|
|
= * (SPAparameter* ) NULL_REF,
|
|
|
SPAparameter&
|
|
|
// actual param
|
|
|
|
= * (SPAparameter* ) NULL_REF
|
|
|
) const;
|
|
|
Tests point-on-curve to given precision, returning its parameter value as well if requested.
|
|
|
|
|
|
|
public: virtual int ellipse::type
() const;
|
|
|
Returns an identifier uniquely specifying the curve type.
|
|
|
|
|
|
|
public: virtual char const*
|
|
|
ellipse::type_name () const;
|
|
|
Returns a string "ellipse".
|
|
|
|
|
|
|
public: virtual logical ellipse::undef
() const;
|
|
|
Indicates whether the ellipse is properly defined.
|
|
Internal Use:
|
full_size
|
|
|
|
|
Related Fncs:
|
restore_ellipse
|
|
|
|
|
|
|
friend: ellipse operator* (
|
|
|
ellipse const&,
|
// ellipse to transform
|
|
|
SPAtransf const&
|
// transformation
|
|
|
);
|
|
|
Returns an ellipse transformed by the given transformation.
|