The parameter NUMBER_OF_POINTS determines how many two-dimensional points are forming the curve. These points are connected by linear, quadratic or cubic splines as specified by an optional keyword (the default is linear_spline ). Since the curve is not automatically closed, i. e. the first and last points are not automatically connected, you'll have to do this by your own if you want a closed curve. The curve thus defined is rotated about the y-axis to form the lathe object which is centered at the origin.
The following examples creates a simple lathe object that looks like a thick cylinder, i. e. a cylinder with a thick wall:
The cylinder has an inner radius of 2 and an outer radius of 3, giving a wall width of 1. It's height is 5 and it's located at the origin pointing up, i. e. the rotation axis is the y-axis. Note that the first and last point are equal to get a closed curve.
The splines that are used by the lathe and prism objects are a little bit difficult to understand. The basic concept of splines is to draw a curve through a given set of points in a determined way. The linear spline is the simplest spline because it's nothing more than connecting consecutive points with a line. This means that the curve that is drawn between two points only depends on those two points. No additional information is taken into account. Quadratic and cubic splines are different in that they do not only take other points into account when connecting two points but they also look smoother and - in the case of the cubic spline - produce smoother transitions at each point.
Quadratic splines are made of quadratic curves. Each of them connects two consecutive points. Since those two points (call them second and third point) aren't enough to describe a quadratic curve the predecessor of the third point is taken into account when the curve is drawn. Mathematically the relationship (their location on the 2-D plane) between the third and fourth point determines the slope of the curve at the third point. The slope of the curve at the second point is out of control. Thus quadratic splines look much smoother than linear splines but the transitions at each point are generally not smooth because the slopes on both sides of the point are different.
Cubic splines overcome the transition problem of quadratic splines because they also take the first point into account when drawing the curve between the second and third point. The slope at the second point is under control now and allows a smooth transition at each point. Thus cubic splines produce the most flexible and smooth curves.
You should note that the number of spline segments, i. e. curves between two points, depends on the spline type used. For linear splines you get n-1 segments connecting the points P[i], i=1,...,n. A quadratic spline gives you n-2 segments because the last point is only used for determining the slope as explained above (thus you'll need at least three points to define a quadratic spline). The same holds for cubic splines where you get n-3 segments with the first and last point used only for slope calculations (thus needing at least four points). If you want to get a closed quadratic and cubic spline with smooth transitions at the end points you have to make sure that in the cubic case P[n-1] = P[2] (to get a closed curve), P[n] = P[3] and P[n-2] = P[1] (to smooth the transition). In the quadratic case P[n-1] = P[1] (to close the curve) and P[n] = P[2].
You should note that the number of spline segments, i. e. curves between two points, depends on the spline type used. For linear splines you get n-1 segments connecting the points P_i, i=1, ..., n. A quadratic spline gives you n-2 segments because the last point is only used for determining the slope as explained above (thus you'll need at least three points to define a quadratic spline). The same holds for cubic splines where you get n-3 segments with the first and last point used only for slope calculations (thus needing at least four points). If you want to get a closed quadratic and cubic spline with smooth transitions at the end points you have to make sure that in the cubic case P_ {n-1} = P_2 (to get a closed curve), P_n = P_3 and P_ {n-2} = P_1 (to smooth the transition). In the quadratic case P_ {n-1} = P_1 (to close the curve) and P_n = P_2 (for a smooth transition).
The slower but more accurate Sturmian root solver may be used with the quadratic spline lathe if the shape does not render properly. Since a quadratic polynomal has to be solved for the linear spline lathe the Sturmian root solver is not needed. In case of cubic splines the Sturmian root solver is always used because a 6th order polynomal has to be solved.
The syntax for the prism is:
The prism object allows you to use any number of sub-prisms inside one prism statement (they are of the same spline and sweep type). Wherever an even number of sub-prisms overlaps a whole appears.
The syntax of the prism object depends on the type of spline curve used. Below the syntax of the linear spline prism is given.
Each of the sub-prisms has to be closed by repeating the first point of a sub-prism at the end of the sub-prism's point sequence. If this is not the case a warning is issued and the prism is ignored (with linear splines automatic closing is used). This implies that all points of a prism are different (except the first and last of course). This applies to all spline types though the control points of the quadratic and cubic splines can be arbitrarily chosen.
The last sub-prism of a linear spline prism is automatically closed - just like the last sub-polygon in the polygon statement - if the first and last point of the sub-polygon's point sequence are not the same. This make it very easy to convert between polygons and prisms. Quadratic and cubic splines are never automatically closed.
The syntax for quadratic spline prisms is:
Quadratic spline sub-prisms need an additional control point at the beginning of each sub-prisms' point sequence to determine the slope at the start of the curve.
Last but not least the syntax for the cubic spline prism.
In addition to the closed point sequence each cubic spline sub-prism needs two control points to determine the slopes at the start and end of the curve.
The parameter TOTAL_NUMBER_OF_POINTS determines how many two-dimensional points (lying in the x-z-plane) form the curves (this includes all control points needed for quadratic and cubic splines). The curves are swept along the y-axis from HEIGHT1 to HEIGHT2 to form the prism object. By default linear sweeping is used to create the prism, i. e. the prism's walls are perpendicular to the x-z-plane (the size of the curve does not change during the sweep). You can also use conic sweeping / conic_sweep that leads to a prism with cone-like walls by scaling the curve down during the sweep.
Like cylinders the prism is normally closed. You can remove the caps on the prism by using the open keyword. If you do so you shouldn't use it with CSG because the results may get wrong.
The following example creates a simple prism object that looks like a piece of cake:
For an explanation of the spline concept read the description of the lathe object.
The slower but more accurate Sturmian root solver may be used with the cubic spline prisms if the shape does not render properly. The linear and quadratic spline prisms do not need the Sturmian root solver.
Where <CENTER> is a vector specifying the x, y, z coordinates of the center of the sphere and RADIUS is a float value specifying the radius. Spheres may be scaled unevenly giving an ellipsoid shape.
Because spheres are highly optimized they make good bounding shapes (if manal bounding seems to be necessary).
The values of e and n, called the east-west and north-south exponent, determine the shape of the superquadric ellipsoid. Both have to be greater than zero. The sphere is e. g. given by e = 1 and n = 1.
The syntax of the superquadric ellipsoid, which is located at the origin, is:
Two useful objects are the rounded box and the rounded cylinder. These are declared in the following way.
The roundedness r determines the roundedness of the edges and has to be greater than zero and smaller than one. The smaller you choose the values of r the smaller and sharper the edges will get.
Very small values of e and n might cause problems with the root solver (the Sturmian root solver cannot be used).
The points <POINT0> through <POINTn-1> are two-dimensional vectors consisting of the radius and the corresponding height, i. e. the position on the rotation axis. These points are smoothly connected (the curve is passing through the specified points) and rotated about the y-axis to form the SOR object. The first and last points are only used to determine the slopes of the function at the start and end point. The function used for the SOR object is similar to the splines used for the lathe object. The difference is that the SOR object is less flexible because it underlies the restrictions of any mathematical function, i. e. to any given point y on the rotation axis belongs at most one function value, i. e. one radius value. You can't rotate closed curves with the SOR object.
The optional keyword open allows you to remove the caps on the SOR object. If you do this you shouldn't use it with CSG anymore because the results may be wrong.
The SOR object is useful for creating bottles, vases, and things like that. A simple vase could look like this:
One might ask why there is any need for a SOR object if there is already a lathe object which is much more flexible. The reason is quite simple. The intersection test with a SOR object involves solving a cubic polynomial while the test with a lathe object requires to solve of a 6th order polynomial (you need a cubic spline for the same smoothness ). Since most SOR and lathe objects will have several segments this will make a great difference in speed. The roots of the 3rd order polynomial will also be more accurate and easier to find.
The slower but more accurate Sturmian root solver may be used with the surface of revolution object if the shape does not render properly.
The following explanations are for the mathematically interested reader who wants to know how the surface of revolution is calculated. Though it is not necessary to read on it might help in understanding the SOR object.
The function that is rotated about the y-axis to get the final SOR object is given by
The coefficients A(j), B(j), C(j) and D(j) are calculated for every segment using the equation
The figure below shows the configuration of the points P(i), the location of segment j, and the curve that is defined by this segment. END
Section 7.5.2.8
Prism
Section 7.5.2.9
Sphere
The geometry of a sphere.
Section 7.5.2.10
Superquadric Ellipsoid
Section 7.5.2.11
Surface of Revolution
r^2 = f(h) = A*h^3 + B*h^2 + C*h + D
with radius r and height h. Since this is a cubic function in h it has enough flexibility to allow smooth curves. The curve itself is defined by a set of n points P(i), i=0...n-1, which are interpolated using one function for every segment of the curve. A segment j, j=1...n-3, goes from point P(j) to point P(j+1) and uses points P(j-1) and P(j+2) to determine the slopes at the endpoints. If there are n points we will have n-3 segments. This means that we need at least four points to get a proper curve.
b = M * x, with
/ \
| r(j)^2 |
| |
| r(j+1)^2 |
b = | |
| 2*r(j)*(r(j+1)-r(j-1))/(h(j+1)-h(j-1)) |
| |
| 2*r(j+1)*(r(j+2)-r(j))/(h(j+2)-h(j)) |
\ /
/ \
| h(j)^3 h(j)^2 h(j) 1 |
| |
| h(j+1)^3 h(j+1)^2 h(j+1) 1 |
M = | |
| 3*h(j)^2 2*h(j) 1 0 |
| |
| 3*h(j+1)^2 2*h(j+1) 1 0 |
\ /
/ \
| A(j) |
| |
| B(j) |
x = | |
| C(j) |
| |
| D(j) |
\ /
where r(j) is the radius and h(j) is the height of point P(j). 
Segment j of n-3 segments in a point configuration of n points. The points describe the curve of a surface of revolution.
Table Of Contents