Difference between revisions of "Revolve"
|Line 1:||Line 1:|
= Overview =
= Overview =
Revision as of 09:19, 23 April 2008
- 1 Overview
- 2 Internal Representation
- 3 General Algorithms
- 4 Additional Features
A solid of revolution can be described by its axis of revolution (point & vector), an angle (-2*pi, 2*pi), and a 2D sketch coplanar with the axis of revolution. The start and end surfaces will be planes, and a positive angle is counterclockwise rotation.
- What is a 2D sketch?
rt_rev_shot() - ray intersection
- Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting.
Or is it better to use the enclosing rpp (not so exact but faster)? Will this be done automatically?
- If (angle != 2*pi) check against the start and end surfaces.
- Check original ray against start surface
- Transform ray (rotate about Z-axis) by -(angle), and check against start surface. (Or store the end surface seperately to avoid the ray transformation.)
Alternatively: Check the ray against the planes at the start and the end (this gives us one intersection point for each plane (in general )). Look if these points are inside the 2D sketches.
- For the revolved portion:
- 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)
- Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points.
Of what degree is this problem? Should we limit the 2D sketch to a spline of at most degree 2 curves to keep the degree small?
- Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.
- 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
- 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.
- 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
- On the revolved portion (similar to toroid calculation):
- Get the curvature in the r-z plane from the precomputed 2D revolve bounds.
- Calculate the curvature in the z-theta plane from r.
- 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:
- Use the precomputed revolve boundary instead of the ellipse/circle for the 2D shape to be revolved.
- Add +/- limits to the angle of the revolve.
- Add the planes at start and end of revolve (if angle != 2*pi).
General Primitive or Combination
Add support for using a 3D primitive or combination as the basis of the revolve.
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.