next up previous contents index
Next: Intersection Up: Geometric Data Structures Previous: Geometric Data Structures   Contents   Index

Triples and Frames

Points and displacements in space are represented as ordered triples. The name of the type is ``P'', though ``triple'' may be used for backward compatibility. Spherical and cylindrical/polar constructors are provided. Standard (and non-standard) algebraic operations--addition/subtraction, scalar multiplication; dot, cross, and componentwise products, and orthogonalization--can be performed on triples. When forming symbolic expressions involving triples, scalars must be collected together at left, triples at right. If necessary, use parentheses to force a particular association.

  P pt(x,y,z);        // define pt = (x,y,z)
  double u=pt.x1();   // first coordinate of pt, etc.
  P(x,y);             // same as P(x, y, 0);
  polar(r, theta);
  cis(t);             // polar(1, t), aka Cos(t) + i*Sin(t)
  sph(r, theta, phi); // theta=longitude, phi=latitude
  P(a,b,c)|P(x,y,z);  // dot product, ax+by+cz
  P(a,b,c)&P(x,y,z);  // componentwise product, P(ax,by,cz)
  p*q;                // cross product, p x q
  J(p);               // quarter turn about the x3-axis
  p%q;                // orthogonalization, p (mod q)
Explicitly, p%q is the unique vector p+k*q that is perpendicular to q.

A frame is a set of three mutually perpendicular unit vectors. The standard frame is the set E_1, E_2, E_3. The constructor turns three non-coplanar vectors into a frame:

  frame(); // the standard frame
  frame(P v1, P v2, P v3); // orthonormalize (v1, v2, v3)
The third vector of the new frame is positively proportional to v3, the second vector is positively proportional to v2%v3, and the first vector is the cross product. Thus, a frame is right-handed, and does not depend on v1.



Andrew D. Hwang 2004-09-04