Revolve

From BRL-CAD
Revision as of 15:27, 10 April 2008 by Pacman87 (talk | contribs) (design document for g_rev.c (GSoC proposal))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

A solid of revolution can be described by its axis of revolution (point & vector), an angle (-2*pi, 2*pi), a primitive or group to be revolved, and a second vector to give the r-z plane ( in cylindrical coordinates, local to the revolve) cutting through the primitive/group to generate the 2D outline to be revolved. The normal vector for this plane is (Vaxis) x (V2), and the plane should terminate at the (local) z-axis.

The start and end surfaces will be flat plates, and a positive angle is counterclockwise rotation.

General Algorithms

rt_rev_shot() - ray intersection

  1. Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting.
  1. If (angle != 2*pi) check against the start and end surfaces.
    1. Check original ray against start surface
    2. Transform ray (rotate about Z-axis) by -(angle), and check against start surface. (Or store the end surface seperately to avoid the ray transformation.)
  1. For the revolved portion:
    1. Flatten out the intersection to 2D (ignore theta): ray becomes hyperbola in the r-z plane (parameterized- use same variable for length along ray as length along hyperbola to keep mapping from 3D to 2D)
    2. Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points.
    3. Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.
    4. Using the actual 3D intersection point, find theta for the hitpoint on the original primitive in local cylindrical coordinates. Check to ensure that the angle of the point from (3) is between (0, revolve angle).

rt_rev_norm() - surface normals @ hitpoint

  1. If the hitpoint is on the precomputed 2D revolve outline, the normal vector will lie in the r-z plane, and it will also be normal to the 2D revolve outline.
  2. Otherwise, the hitpoint is on the plane at the start or end of the revolve, and the normal vectors for each plane can be stored to speed calculations.

rt_rev_curve() - surface curvature @ hitpoint

  1. On the revolved portion (similar to toroid calculation):
    1. Get the curvature in the r-z plane from the precomputed 2D revolve bounds.
    2. Calculate the curvature in the z-theta plane from r.
  2. On the planes at the limits of the revolve, the curvature will be 0.

rt_rev_plot() & rt_rev_tess()

plot() and tess() can be done using the same basic algorithm that the toroids use, with some modifications:

  1. Use the precomputed revolve boundary instead of the ellipse/circle for the 2D shape to be revolved.
  2. Add +/- limits to the angle of the revolve.
  3. Add the planes at start and end of revolve (if angle != 2*pi).

Additional Features

End Caps

This would keep the first half of the primitive or group being revolved at the start plane, and add a copy of the primitive/group to the end. If this was applied to a cone over 90 degrees, where the cross-section used for the revolve was a circle, the result would be a frustum attached to right angle pipe curve, with a cone at the tip.

Complex End Conditions

This would create a partial revolve (angle < 2*pi) with a 3D shape where the maximum outline does not fall in a r-z plane. A 2D example of this is revolving an ellipse with focii at (4,1) and (6, -1) about the z axis. For this case, the minimum radius and maximum radius do not occur along the same plane. If the end cap method (above) was used, there would be an abrubt transition from the ellipse to the revolved body.

This feature can best be implemented by using a sweep along a circular path, becasue the sweep primitive will need to handle this end condition for sweeping any other general 3D primitive. This approach minimizes code duplication, and keeps the revolve primitive focused specifically on revolving.