sphere
List of: Classes
Subjects: Construction Geometry, SAT Save and Restore
Contents: Kernel

Purpose: Defines a spherical surface.

Derivation: sphere : surface : ACIS_OBJECT : -

SAT Identifier: "sphere"

Filename: kern/kernel/kerngeom/surface/sphdef.hxx

Description: A sphere is defined by a center point and radius. A positive radius indicates an outward pointing surface normal. A negative radius indicates an inward pointing surface normal.


Five data members define the parameterization of the sphere and they are described in "Data."


The u-parameter is the latitude metric, running from -pi/2 at the south pole through 0 at the equator to pi/2 at the north pole. The v-parameter is the longitude metric, running from -pi to pi, with 0 on the meridian containing ori_dir, and increasing in a clockwise direction around pole_dir, unless reverse_v is TRUE.


Let P be pole_dir and Qori_dir, and let R be P x Q, negated if reverse_v is TRUE. Let r be the absolute value of the sphere radius. Then:


pos = center + r* sin(u)* P + r* cos(u)*



(cos(v)* Q + sin(v) R)


This parameterization is left-handed for a convex sphere and right-handed for a hollow one, if reverse_v is FALSE, and reversed if it is TRUE.


When the sphere is transformed, the sense of reverse_v is inverted if the transform includes a reflection. No special action is required for a negation.


In summary, spheres are:


- Not true parametric surfaces.

- Periodic in v (-pi to pi with period 2 * pi) but not in u.

- Closed in v but not in u.

- Singular in u at the poles; nonsingular everywhere else.

References: by KERN SPHERE

BASE SPAposition, SPAunit_vector

Data: public logical reverse_v;

Constant u-parameter lines are circles around pole_dir, normally clockwise, but counterclockwise if this is TRUE.


public SPAposition centre;

The center of the sphere.


public double radius;

The radius of a sphere. If negative, the surface normal points inward to the center of the sphere.


public SPAunit_vector pole_dir;

Direction normal to uv_oridir that points from the center to the "north pole" of the sphere; i.e., the maximum-u singularity.


public SPAunit_vector uv_oridir;

Direction from the center of the sphere to the origin of parameter space.

Constructor: public: sphere::sphere ();


C++ allocation constructor requests memory for this object but does not populate it.






public: sphere::sphere (


SPAposition const&, // position


double // radius


);


C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.






public: sphere::sphere (


sphere const& // given sphere


);


C++ copy constructor requests memory for this object and populates it with the data from the object supplied as an argument.




Destructor: public: sphere::~sphere ();


C++ destructor, deleting a sphere.



Methods: public: virtual int sphere::accurate_derivs (


SPApar_box const& // parameter box name



= * (SPApar_box* ) NULL_REF


) const;


Returns the number of derivatives that evaluate can find accurately (and 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_SURFACE_DERIVATIVES. This is the case with a sphere.






public: virtual SPAbox sphere::bound (


SPAbox const&, // box


SPAtransf const& // transformation



= * (SPAtransf* ) NULL_REF


) const;


Returns a box that encloses the surface in object space.






public: virtual SPAbox sphere::bound (


SPApar_box const& // parameter space box



= * (SPApar_box* ) NULL_REF,


SPAtransf const& // transformation



= * (SPAtransf* ) NULL_REF


) const;


Returns a box that encloses the surface in parameter space.






public: virtual logical sphere::closed_u () const;


Reports whether the surface is closed, smoothly or not, in the u-parameter direction. A sphere is open in the u-direction.






public: virtual logical sphere::closed_v () const;


Reports whether the surface is closed, smoothly or not, in the v-parameter direction. A sphere is closed in the v-direction






public: virtual void sphere::debug (


char const*, // leader string


FILE* // file pointer



= debug_file_ptr


) const;


Prints out details of sphere.






public: virtual surface* sphere::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 void sphere::eval (


SPApar_pos const&, // parameter position


SPAposition&, // position


SPAvector* // 1st derivatives array



= NULL, // length 2, in order xu,




// xv


SPAvector* // second derivatives -



= NULL // array of length 3, in




// order xuu, xuv, xvv


) const;


Finds the point on a parametric surface with given parameter values, and optionally the first and second derivatives as well or instead.






public: virtual int sphere::evaluate (


SPApar_pos const&,

// param position


SPAposition&,

// pt on surface






// at given






// param position


SPAvector**

// array of ptrs



= NULL,

// to arrays of






// vectors


int


// number of



= 0,

// derivatives






// required


evaluate_surface_quadrant
// the evaluation






// location






// above, below






// for each






// parameter






// dir., or don't



= evaluate_surface_unknown // care.


) const;


Calculates derivatives, of any order up to the number requested, and stores them in vectors provided by the user. The function returns the number of derivatives calculated. Any of the pointers may be NULL, in which case the corresponding derivatives will not be returned. Otherwise they must point to arrays long enough for all the derivatives of that order - i.e., 2 for the first derivatives, 3 for the second, etc.






public: virtual double sphere::eval_cross (


SPApar_pos const&, // parameter position


SPAunit_vector const& // direction


) const;


Finds the curvature of a cross-section curve of the parametric surface at the point with given parameter values. The cross-section curve is given by the intersection of the surface with a plane passing through the point and with given normal.






public: virtual SPAunit_vector sphere::eval_normal (


SPApar_pos const& // parameter position


) const;


Finds the normal to a parametric surface at a point with given parameter values.






public: surf_princurv sphere::eval_prin_curv (


SPApar_pos const& param // parameter position


) const;


Finds the principle axes of curvature and the curvatures in those directions of the surface at a point with given parameter values. For a sphere, the curvature in every direction is a constant, so the direction of the principle axes is arbitrary.






public: virtual void sphere::eval_prin_curv (


SPApar_pos const&, // parameter


SPAunit_vector&, // first axis direction


double&, // curvature in the first




// direction


SPAunit_vector&, // second axis direction


double& // curvature in the 2nd




// direction


) const;


Finds the principle axes of curvature and the curvatures in those directions of the surface at a point with given parameter values. For a sphere, the curvature in every direction is a constant, so the direction of the principle axes is arbitrary.






public: logical sphere::hollow () const;


Determines if a sphere is hollow.






public: virtual logical


sphere::left_handed_uv () const;


Indicates whether the parameter coordinate system of the surface is right-handed or left-handed.


With a right-handed system, at any point the outward normal is given by the cross product of the increasing u-direction with the increasing v-direction, in that order. With a left-handed system the outward normal is in the opposite direction from this cross product.






public: virtual surface* sphere::make_copy () const;


Makes a copy of this sphere on the heap, and returns a pointer to it.






public: virtual surface& sphere::negate ();


Negates this sphere.






public: virtual surf_normcone sphere::normal_cone (


SPApar_box const&, // parameter bounds


logical // approx. results OK?



= FALSE,


SPAtransf const& // transformation



= * (SPAtransf* ) NULL_REF


) const;


Returns a cone bounding the normal direction of a curve.


The cone is deemed to have its apex at the origin, and has 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 completely inside or 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 surface& sphere::operator*= (


SPAtransf const& // transformation


);


Transforms this sphere by the given transform.






public: sphere sphere::operator- () const;


Returns a copy of this sphere negated; i.e., with normal reversed.






public: virtual logical sphere::operator== (


surface const& // surface name


) const;


Tests two surfaces for equality.


This, like testing floating point numbers for equality, is not guaranteed to say equal for effectively equal surfaces, but is guaranteed to say not equal if they are indeed not equal. The result can be used for optimization, but not where it really matters.






public: virtual SPApar_pos sphere::param (


SPAposition const&, // position


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF


) const;


Finds the parameter values of a point on a surface, given an optional first guess.






public: virtual logical sphere::parametric () const;


Determines if a sphere is parametric. A sphere is not considered to be parametric.






public: virtual double


sphere::param_period_u () const;


Return the period of a periodic parametric surface, or 0 if the surface is not periodic in the u-parameter or not parametric. A sphere is not periodic in the u-direction.






public: virtual double


sphere::param_period_v () const;


Return the period of a periodic parametric surface, or 0 if the surface is not periodic in the v-parameter or not parametric. A sphere has a period of 2 * pi in the v-direction.






public: virtual SPApar_box sphere::param_range (


SPAbox const& // box name



= * (SPAbox* ) NULL_REF


) const;


Returns the parameter ranges of the portion of a surface lying within the given box.






public: virtual SPAinterval sphere::param_range_u (


SPAbox const& // box name



= * (SPAbox* ) NULL_REF


) const;


Returns the parameter ranges of the portion of a surface that lies within the given box in a u-parameter direction.






public: virtual SPAinterval sphere::param_range_v (


SPAbox const& // box name



= * (SPAbox* ) NULL_REF


) const;


Returns the parameter ranges of the portion of a surface that lies within the given box in a v-parameter direction.






public: virtual SPApar_vec sphere::param_unitvec (


SPAunit_vector const&, // direction


SPApar_pos const& // parameter position


) const;


Finds the rate of change in surface parameter corresponding to a unit velocity in a given object-space direction at a given position in parameter space.






public: virtual logical sphere::periodic_u () const;


Reports whether the surface is periodic in the u-parameter direction; i.e., it is smoothly closed, so faces can run over the seam. A sphere is not periodic in the u-direction.






public: virtual logical sphere::periodic_v () const;


Reports whether the surface is periodic in the v-parameter direction; i.e., it is smoothly closed, so faces can run over the seam. A sphere is not periodic in the v-direction.






public: virtual double sphere::point_cross (


SPAposition const&, // position


SPAunit_vector const&, // direction


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF


) const;


Returns the curvature of a curve in the surface through a given point normal to a given direction in the surface. The curvature of a sphere is 1/radius in all directions, at all locations.






public: virtual SPAunit_vector sphere::point_normal (


SPAposition const&, // position


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF


) const;


Returns the surface normal at a given point on the surface.






public: virtual void sphere::point_perp (


SPAposition const&, // first position


SPAposition&, // second position


SPAunit_vector&, // direction


surf_princurv&, // surf. principle curve


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF,


SPApar_pos& // parameter position



= * (SPApar_pos* ) NULL_REF,


logical f_weak // weak flag



= FALSE


) const;


Finds the point on the surface nearest to the given point. Optionally, the function may determine the normal to and principal curvatures of the surface at that point. If the surface is parametric, also return the parameter values at the found point.






public: void sphere::point_perp (


SPAposition const& pos,

// position


SPAposition& foot,

// foot position


SPApar_pos const& param_guess // possible param



= * (SPApar_pos* ) NULL_REF,


SPApar_pos& param_actual

// actual param



= * (SPApar_pos* ) NULL_REF,


logical f_weak

// weak flag



= FALSE


) const;


Finds the point on the surface nearest to the given point. If the surface is parametric, also return the parameter values at the found point.






public: void sphere::point_perp (


SPAposition const& pos,

// position


SPAposition& foot,

// foot position


SPAunit_vector& norm,

// direction


SPApar_pos const& param_guess // possible param



= * (SPApar_pos* ) NULL_REF,


SPApar_pos& param_actual

// actual param



= * (SPApar_pos* ) NULL_REF,


logical f_weak

// weak flag



= FALSE


) const;


Finds the point on the surface nearest to the given point. Optionally, the function may determine the normal to the surface at that point. If the surface is parametric, also return the parameter values at the found point.






public: surf_princurv sphere::point_prin_curv (


SPAposition const& pos,
// position


SPApar_pos const& param_guess// parameter



= * (SPApar_pos* ) NULL_REF// position


) const;


Finds the principal axes of curvature of the surface at a given point, and the curvatures in those directions.






public: virtual void sphere::point_prin_curv (


SPAposition const&, // position


SPAunit_vector&, // first axis direction


double&, // curvature in first




// direction


SPAunit_vector&, // second axis direction


double&, // curvature in second




// direction


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF


) const;


Finds the principal axes of curvature of the surface at a given point, and the curvatures in those directions.






public: void sphere::restore_data ();


Restore the data for a sphere from a save file.


read_position Center of sphere

read_real Radius of sphere

if (restore_version_number < SURFACE_VERSION)

// Old style - that is all to read.

else

read_unit_vector uv x-axis

read_unti_vector pole direction (z-axis)

read_logical Reverse v; either "forward_v" or "reversed_v"

surface::restore_data
Restore remainder of surface data






public: virtual void sphere::save () const;


Saves the type or id, then calls save_data.






public: void sphere::save_data () const;


Saves the information for sphere in the save file.






public: virtual logical sphere::singular_u (


double // constant u-parameter


) const;


Reports whether the surface parameterization is singular at the specified u-parameter value. A sphere is singular in u at both poles.






public: virtual logical sphere::singular_v (


double // constant v-parameter


) const;


Reports whether the surface parameterization is singular at the specified v-parameter value. A sphere is not singular in v anywhere.






public: virtual logical sphere::test_point_tol (


SPAposition const&, // position


double // parameter



= 0,


SPApar_pos const& // parameter position



= * (SPApar_pos* ) NULL_REF,


SPApar_pos& // parameter



= * (SPApar_pos* ) NULL_REF


) const;


Tests whether a point lies on the surface, to user-supplied precision.






public: virtual int sphere::type () const;


Returns the type of sphere.






public: virtual char const*


sphere::type_name () const;


Returns the string "sphere".






public: virtual logical sphere::undef () const;


Verifies if the sphere is properly defined.






public: virtual curve* sphere::u_param_line (


double // constant v-parameter


) const;


Constructs a parameter line on the surface.


A u-parameter line runs in the direction of increasing u-parameter, at constant v. The parameterization in the nonconstant direction matches that of the surface, and has the range obtained by use of param_range_u. The new curve is constructed in free store, so it is the responsibility of the caller to ensure that it is correctly deleted.






public: virtual curve* sphere::v_param_line (


double //constant u-parameter


) const;


Constructs a parameter line on the surface.


A v-parameter line runs in the direction of increasing v, at constant u. The parameterization in the nonconstant direction matches that of the surface, and has the range obtained by use of param_range_v. The new curve is constructed in free store, so it is the responsibility of the caller to ensure that it is correctly deleted.

Internal Use: full_size




Related Fncs: restore_cone






friend: sphere operator* (


sphere const&, // sphere name


SPAtransf const& // transform to use


);


Transforms a sphere surface.
PDF/KERN/36CLSA.PDF
HTM/DATA/KERN/KERN/36CLSA/0006.HTM