Bounding Boxes for Circle and Arcs in 3D

Posted by David Rutten on Stack Overflow See other posts from Stack Overflow or by David Rutten
Published on 2010-04-07T11:33:56Z Indexed on 2010/04/07 18:53 UTC
Read the original article Hit count: 415

Filed under:
|
|

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);
}

© Stack Overflow or respective owner

Related posts about math

Related posts about 3d