Difference between revisions of "Revolve"

From BRL-CAD
m (Complex End Conditions)
 
(3 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
= Overview =
 
= Overview =
  
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.
+
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.  There are several options for how to specify the start and end planes. Starseeker suggests using:
 +
* a vector 'r' such that <axis> x <r> = direction of revolution
 +
* an angle
 +
 
 +
In order to analytically solve for the ray/shape intersection points, the sketch must be limited to splines of at most second order.
  
 
= Internal Representation =
 
= Internal Representation =
  
 
struct rt_revolve_internal:
 
struct rt_revolve_internal:
* point_t origin;
+
* point_t V3D;
* vect_t  start_normal;
+
* vect_t  axis3D;
* vect_t  end_normal;
+
* point2d_t V2D;
 
+
* vect2d_t  axis2D
The start/end surface is determined by one point on it (''origin'') and its normal (''start_normal''/''end_normal'').
+
* vect_t  r;
''start_normal'' points to the rotation direction.
+
* fastf_t angle;
The intersection of the two surfaces (the rotation axis) corresponds to the y-axis of the sketch.
+
* char *sketch_name;
 +
* struct rt_sketch_internal *sk;
  
'''Open questions:'''
+
''Questions:''
* What is a 2D sketch?
+
Should the sketch be restricted to revolve about its y-axis, or should I allow for an arbitrary point & axis defined in the sketch plane (*2D)?
 +
If yes, the sketch would undergo a rotation/translation - is rotation/translation of a sketch already possible? If it is possible, then restricting to the y-axis will not limit the user.
  
 
= General Algorithms =
 
= General Algorithms =
Line 23: Line 29:
 
== rt_rev_shot() - ray intersection ==
 
== rt_rev_shot() - ray intersection ==
  
#Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting. <br/> '''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.
 
#If (angle != 2*pi) check against the start and end surfaces.
##Check original ray against start surface
+
##Find the parameter values for the intersection of the ray with the start/end surfacesThese two plane intersections will give the bounds on the parameter for intersections.  In some cases, there will only be an upper or lower bound.
##Transform ray (rotate about Z-axis) by -(angle), and check against start surface(Or store the end surface seperately to avoid the ray transformation.) <br/> '''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.'''
+
##Check if the plane intersection point(s) are inside the 2D sketch.
 
#For the revolved portion:
 
#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)
 
##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. <br/> '''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?'''
+
##Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points.
##Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.
+
##Check the parameter value against the bounds determined in 1.1.
##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 ==
 
== rt_rev_norm() - surface normals @ hitpoint ==
Line 63: Line 67:
 
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 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.
+
This feature can best be implemented by using a sweep along a circular path, because 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.

Latest revision as of 11:06, 3 January 2020

Design icon.png This page contains the design document for an enhancement or feature. The design should be considered a work in progress and may not represent the final design. As this is a collaborative design, contributions and participation from other developers and users is encouraged. Use the discussion page for providing comments and suggestions.


Overview[edit]

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. There are several options for how to specify the start and end planes. Starseeker suggests using:

  • a vector 'r' such that <axis> x <r> = direction of revolution
  • an angle

In order to analytically solve for the ray/shape intersection points, the sketch must be limited to splines of at most second order.

Internal Representation[edit]

struct rt_revolve_internal:

  • point_t V3D;
  • vect_t axis3D;
  • point2d_t V2D;
  • vect2d_t axis2D
  • vect_t r;
  • fastf_t angle;
  • char *sketch_name;
  • struct rt_sketch_internal *sk;

Questions: Should the sketch be restricted to revolve about its y-axis, or should I allow for an arbitrary point & axis defined in the sketch plane (*2D)? If yes, the sketch would undergo a rotation/translation - is rotation/translation of a sketch already possible? If it is possible, then restricting to the y-axis will not limit the user.

General Algorithms[edit]

rt_rev_shot() - ray intersection[edit]

  1. If (angle != 2*pi) check against the start and end surfaces.
    1. Find the parameter values for the intersection of the ray with the start/end surfaces. These two plane intersections will give the bounds on the parameter for intersections. In some cases, there will only be an upper or lower bound.
    2. Check if the plane intersection point(s) are inside the 2D sketch.
  2. 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. Check the parameter value against the bounds determined in 1.1.

rt_rev_norm() - surface normals @ hitpoint[edit]

  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[edit]

  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()[edit]

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[edit]

General Primitive or Combination[edit]

Add support for using a 3D primitive or combination as the basis of the revolve.

End Caps[edit]

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[edit]

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, because 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.