A surface is defined with a 2D matrix of points. Triangles that fill the
surface are created between neighboring points in the matrix.
If a surface is defined with 9 points (an array or arrays in JavaScript):
Then triangles will be created between adb, deb, bec, efc, dge,
ghe, ehf, and hif.
The normal for triangle 'adb' is in the direction of the cross product
of vector 'ad' with vector 'ab' (use the right hand rule where the fingers
of the right hand curl from vector 'ad' to 'ab', and the thumb will then be
the direction of the normal). Similarly, the normal of hif will be the
direction of the cross product of hi with hf.
Use the property invertNormals to make all the normals go in the reverse
direction.
A surface can be open or closed at the end rows or columns of the matrix.
For example, a surface has closed columns if the first and last column
of the matrix have identical points. A surface is has open rows if the first
and last row of the matrix have different points.
If using curved normals ('curve', 'curveRows' or 'curveColumns') with
closed surfaces, use closeRows or closeColumns to ensure normal
curvature is maintained at the end rows
and columns.
// Create a matrix of points by taking a profile in XY and rotating // it around the x axis const { Point, Transform } = Fig; constpoints = [];
// Rotation step constdr = Math.PI * 2 / 50; for (letr = 0; r < Math.PI * 2 + dr / 2; r += dr) { // Rotation matrix of rotation step around x axis constm = newTransform().rotate(r, 1, 0, 0).matrix();
// A row of points is a profile rotated by some amount r points.push([]); // Make a profile for x values from 0 to 1 for (letx = 0; x < 1; x += 0.05) { // The y coordinate of the profile changes with both x value, and // rotation value consty = 0.1 * Math.sin(6 * x) + 0.25 + 0.1 * Math.cos(3 * r); constp = newPoint(x, y).transformBy(m); points[points.length - 1].push(p); } } figure.add({ make:'surface', points, color: [1, 0, 0, 1], }); @interface
Surface shape options object that extends OBJ_Generic3All and OBJ_FigurePrimitive.
A surface is defined with a 2D matrix of points. Triangles that fill the surface are created between neighboring points in the matrix.
If a surface is defined with 9 points (an array or arrays in JavaScript):
Then triangles will be created between
adb,deb,bec,efc,dge,ghe,ehf, andhif.The normal for triangle 'adb' is in the direction of the cross product of vector 'ad' with vector 'ab' (use the right hand rule where the fingers of the right hand curl from vector 'ad' to 'ab', and the thumb will then be the direction of the normal). Similarly, the normal of
hifwill be the direction of the cross product ofhiwithhf.Use the property
invertNormalsto make all the normals go in the reverse direction.A surface can be open or closed at the end rows or columns of the matrix. For example, a surface has closed columns if the first and last column of the matrix have identical points. A surface is has open rows if the first and last row of the matrix have different points.
If using curved normals (
'curve','curveRows'or'curveColumns') with closed surfaces, usecloseRowsorcloseColumnsto ensure normal curvature is maintained at the end rows and columns.See
To test examples, append them to the boilerplate
Example
Example
Example
Example
Example
Example