Analytic Shapes

Utility classes used to represent closed shapes with an implicit function. They must all have the same interface.

class Capsule

Represents a capsule.

A capsule is represented by a segment and a radius. Its surfae is the set of points whose distance to the segment is equal to the radius.

In more visual terms, a capsule looks like a finite cylinder with two half spheres on its ends.

The capsule is centered at the origin and oriented along the z axis.

Public Functions

Capsule(real R, real L)

Construct a Capsule.

Parameters
  • R: the radius of the capsule. Must be positive.
  • L: the length of the segment used to represent the capsule. Must be positive.

real inOutFunction(real3 r) const

Implicit surface representation.

This scalar field is a smooth function of the position. It is negative inside the capsule and positive outside. The zero level set of that field is the surface of the capsule.

Return
The value of the field at the given position.
Parameters
  • r: The position at which to evaluate the in/out field.

real3 normal(real3 r) const

Get the normal pointing outside the capsule.

This vector field is defined everywhere in space. On the surface, it represents the normal vector of the surface.

Return
The normal at r (length of this return must be 1).
Parameters
  • r: The position at which to evaluate the normal.

real3 inertiaTensor(real totalMass) const

Get the inertia tensor of the capsule in its frame of reference.

Return
The diagonal of the inertia tensor.
Parameters
  • totalMass: The total mass of the capsule.

Public Static Attributes

const char *desc

the description of shape.

class Cylinder

Represents a finite cylinder.

The cylinder is centered at the origin and is oriented along the z axis. It is fully described by its length and its radius.

Public Functions

Cylinder(real R, real L)

Constructs a Cylinder.

Parameters
  • R: the radius of the cylinder. Must be positive
  • L: the length of the cylinder. Must be positive.

real inOutFunction(real3 r) const

Implicit surface representation.

This scalar field is a smooth function of the position. It is negative inside the cylinder and positive outside. The zero level set of that field is the surface of the cylinder.

Return
The value of the field at the given position.
Parameters
  • r: The position at which to evaluate the in/out field.

real3 normal(real3 r) const

Get the normal pointing outside the cylinder.

This vector field is defined everywhere in space. On the surface, it represents the normal vector of the surface.

Return
The normal at r (length of this return must be 1).
Parameters
  • r: The position at which to evaluate the normal.

real3 inertiaTensor(real totalMass) const

Get the inertia tensor of the cylinder in its frame of reference.

Return
The diagonal of the inertia tensor.
Parameters
  • totalMass: The total mass of the cylinder.

Public Static Attributes

const char *desc

the description of shape.

class Ellipsoid

Represents an ellipsoid.

The ellipsoid is centered at the origin and oriented along its principal axes. the three radii are passed through the axes variable. The surface is described implicitly by the zero level set of:

\[\left( \frac {x} {a_x} \right)^2 + \left( \frac {y} {a_y} \right)^2 + \left( \frac {z} {a_z} \right)^2 = 1\]

Public Functions

Ellipsoid(real3 axes)

Construct a Ellipsoid object.

Parameters
  • axes: the “radius” along each principal direction.

real inOutFunction(real3 r) const

Implicit surface representation.

This scalar field is a smooth function of the position. It is negative inside the ellipsoid and positive outside. The zero level set of that field is the surface of the ellipsoid.

Return
The value of the field at the given position.
Parameters
  • r: The position at which to evaluate the in/out field.

real3 normal(real3 r) const

Get the normal pointing outside the ellipsoid.

This vector field is defined everywhere in space. On the surface, it represents the normal vector of the surface.

Return
The normal at r (length of this return must be 1).
Parameters
  • r: The position at which to evaluate the normal.

real3 inertiaTensor(real totalMass) const

Get the inertia tensor of the ellipsoid in its frame of reference.

Return
The diagonal of the inertia tensor.
Parameters
  • totalMass: The total mass of the ellipsoid.

Public Static Attributes

const char *desc

the description of shape.