tags:

views:

192

answers:

1

Given curves of type Circle and Circular-Arc in 3D space, what is a good way to compute accurate bounding boxes (world axis aligned)?


Edit: found solution for circles, still need help with Arcs.

C# snippet for solving BoundingBoxes for Circles:

public static BoundingBox CircleBBox(Circle circle)
{
  Point3d O = circle.Center;
  Vector3d N = circle.Normal;

  double ax = Angle(N, new Vector3d(1,0,0));
  double ay = Angle(N, new Vector3d(0,1,0));
  double az = Angle(N, new Vector3d(0,0,1));

  Vector3d R = new Vector3d(Math.Sin(ax), Math.Sin(ay), Math.Sin(az));
  R *= circle.Radius;

  return new BoundingBox(O - R, O + R);
}

private static double Angle(Vector3d A, Vector3d B)
{
  double dP = A * B;
  if (dP <= -1.0) { return Math.PI; }
  if (dP >= +1.0) { return 0.0; }

  return Math.Acos(dP);
}
+1  A: 
brainjam