Re: pfBox and pfSphere

New Message Reply Date view Thread view Subject view Author view

Michael T. Jones (mtj++at++babar.asd.sgi.com)
Mon, 8 Jul 1996 11:07:47 -0700


On Jul 8, 11:30am, Steve Baker wrote:
> Subject: pfBox and pfSphere
>
> Is there an 'official' way to distinguish an empty pfBox or pfSphere?

no, but there should be. see the code fragments below for guidance.

> The man pages don't indicate the existance of a pfIsEmptyBox or
> pfIsEmptySPhere - but they hint that there is a 'special' representation
> for empty boxes and spheres.
>
> By experiment I see that empty Spheres have a center at (0,0,0) and a radius
> of -1.0, and pfBox'es have really large numbers for 'min' and really large
> negative numbers for 'max'.

Here's the code...

void
pfBox::makeEmpty()
{
    PFSET_VEC3(min, PF_HUGEVAL, PF_HUGEVAL, PF_HUGEVAL);
    PFSET_VEC3(max, -PF_HUGEVAL, -PF_HUGEVAL, -PF_HUGEVAL);
}

void
pfSphere::makeEmpty()
{
    center.set(0.0f, 0.0f, 0.0f);
    radius = -1.0f;
}

void
pfCylinder::makeEmpty()
{
    PFSET_VEC3(center, 0.0f, 0.0f, 0.0f);
    PFSET_VEC3(axis, 1.0f, 0.0f, 0.0f);
    radius = -1.0f;
    halfLength = -1.0f;
}

> What's not clear is exactly which of these criteria are 'safe' tests for
emptyness.
>
> (eg if I test for a sphere of radius != -1.0, will I get into trouble if I
scale
> the sphere with pfOrthoXformSphere and end up with a radius of -2.0. Is it OK
> to test for a negative radius?)

Safe Tests:

Box: max < min in any dimension makes that dimension undefined. a more
  cautious definition is that max < min in any dimension makes for an
  empty box.

Sphere and Cylinder: radius < 0 (or halfLength < 0) make means empty.
  sphere transformation scales the radius by an always positive length
  so even an attempted scaling by -1 can't invert the sign of the radii.

> Maybe these tests should be added to Performer in a future release.

good point. one semantic issue is that a box can be "partially empty"
(used for single or dual axis extents) and so we also need a rigorous
definition for this notion (YES, NO, KIND-OF)

michael jones

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ <--new!
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:09 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.