Editing Revolve
From BRL-CAD
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
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. |
− | |||
− | |||
− | |||
− | |||
= Internal Representation = | = Internal Representation = | ||
struct rt_revolve_internal: | struct rt_revolve_internal: | ||
− | * point_t | + | * point_t origin; |
− | * vect_t | + | * vect_t start_normal; |
− | * | + | * vect_t end_normal; |
− | + | ||
− | + | The start/end surface is determined by one point on it (''origin'') and its normal (''start_normal''/''end_normal''). | |
− | + | ''start_normal'' points to the rotation direction. | |
− | + | ||
− | + | The intersection of the two surfaces is the rotation axis. | |
+ | The direction of this axis has to result in an counter-clockwise rotation. | ||
+ | |||
+ | The rotation axis corresponds to the y-axis of the sketch. | ||
+ | The vectorproduct <''start_normal''>x<rotation axis> corresponds to the x-axis of the sketch (on the start surface). | ||
+ | And ''origin'' corresponds to the (0,0) point of the sketch. | ||
− | '' | + | '''Open questions:''' |
− | + | * What is a 2D sketch? | |
− | |||
= General Algorithms = | = General Algorithms = | ||
Line 29: | 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 |
− | + | ##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.''' | |
#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. | + | ##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?''' |
− | ## | + | ##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 == | == rt_rev_norm() - surface normals @ hitpoint == | ||
Line 67: | Line 69: | ||
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, | + | 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. |