Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bounding Boxes for Circle and Arcs in 3D

Tags:

math

geometry

3d

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);
}
like image 567
David Rutten Avatar asked Apr 07 '10 11:04

David Rutten


People also ask

What is bounding box in 3d?

A bounding box is a cuboid, or in 2-D a rectangle, containing the object. In dynamical simulation, bounding boxes are preferred to other shapes of bounding volume such as bounding spheres or cylinders for objects that are roughly cuboid in shape when the intersection test needs to be fairly accurate.

How do you find the bounding box?

The four sides of the rectangle are always either vertical or horizontal, parallel to the x or y axis. In the figure above, the bounding box is shown drawn around the vertices of a quadrilateral ABCD. It is called the bounding box because it forms a boundary, like a fence, around the shape or set of points.

What is a type bounding box?

It is the rectangle formed by selecting the maximum and minimum horizontal and vertical coordinates in each vertex of the two-dimensional shape and is one of the most commonly used bounding box types. ...


1 Answers

One thing that's not specified is how you convert that angle range to points in space. So we'll start there and assume that the angle 0 maps to O + r***X** and angle π/2 maps to O + r***Y**, where O is the center of the circle and X = (x1,x2,x3) and Y = (y1,y2,y3) are unit vectors.

So the circle is swept out by the function

P(θ) = O + rcos(θ)X + rsin(θ)Y where θ is in the closed interval [θstartend].

The derivative of P is

P'(θ) = -rsin(θ)X + rcos(θ)Y

For the purpose of computing a bounding box we're interested in the points where one of the coordinates reaches an extremal value, hence points where one of the coordinates of P' is zero.

Setting -rsin(θ)xi + rcos(θ)yi = 0 we get tan(θ) = sin(θ)/cos(θ) = yi/xi.

So we're looking for θ where θ = arctan(yi/xi) for i in {1,2,3}.

You have to watch out for the details of the range of arctan(), and avoiding divide-by-zero, and that if θ is a solution then so is θ±k*π, and I'll leave those details to you.

All you have to do is find the set of θ corresponding to extremal values in your angle range, and compute the bounding box of their corresponding points on the circle, and you're done. It's possible that there are no extremal values in the angle range, in which case you compute the bounding box of the points corresponding to θstart and θend. In fact you may as well initialize your solution set of θ's with those two values, so you don't have to special case it.

like image 175
brainjam Avatar answered Oct 17 '22 23:10

brainjam