JSModeler Generator Documentation
JSM.GenerateRectangle
Description
Generates a rectangle. The center of the rectangle will be the origo.
Parameters
xSize |
number |
X size of the rectangle. |
ySize |
number |
Y size of the rectangle. |
Example
var body = JSM.GenerateRectangle (1.0, 1.0);
JSM.GenerateCuboid
Description
Generates a cuboid. The center of the cuboid will be the origo.
Parameters
xSize |
number |
X size of the cuboid. |
ySize |
number |
Y size of the cuboid. |
zSize |
number |
Z size of the cuboid. |
Example
var body = JSM.GenerateCuboid (1.0, 1.0, 1.0);
JSM.GenerateCuboidSides
Description
Generates cuboid sides. The center of the cuboid will be the origo.
Parameters
xSize |
number |
X size of the cuboid. |
ySize |
number |
Y size of the cuboid. |
zSize |
number |
Z size of the cuboid. |
sides |
[boolean] |
Generate value for each side. |
Example
var body = JSM.GenerateCuboidSides (1.0, 1.0, 1.0, [1, 1, 1, 0, 1, 0]);
JSM.GenerateSegmentedRectangle
Description
Generates a rectangle with segmented sides. The center of the rectangle will be the origo.
Parameters
xSize |
number |
X size of the rectangle. |
ySize |
number |
Y size of the rectangle. |
segmentation |
integer |
Segmentation number. |
Example
var body = JSM.GenerateSegmentedRectangle (1, 1, 4);
JSM.GenerateSegmentedCuboid
Description
Generates a cuboid with segmented sides. The center of the cuboid will be the origo.
Parameters
xSize |
number |
X size of the cuboid. |
ySize |
number |
Y size of the cuboid. |
zSize |
number |
Z size of the cuboid. |
segmentation |
integer |
Segmentation number. |
Example
var body = JSM.GenerateSegmentedCuboid (1, 1, 1, 4);
JSM.GenerateCircle
Description
Generates a circle. The center of the circle will be the origo.
Parameters
radius |
number |
Radius of the circle. |
segmentation |
integer |
Segmentation number. |
Example
var body = JSM.GenerateCircle (1.0, 50);
JSM.GenerateSphere
Description
Generates a sphere. The center of the sphere will be the origo.
Parameters
radius |
number |
Radius of the sphere. |
segmentation |
integer |
Segmentation number. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateSphere (1, 50, true);
JSM.GenerateTriangulatedSphere
Description
Generates a sphere from triangles. The center of the sphere will be the origo.
Parameters
radius |
number |
Radius of the sphere. |
segmentation |
integer |
Segmentation number. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateTriangulatedSphere (1, 3, true);
JSM.GenerateCylinder
Description
Generates a cylinder. The center of the cylinder will be the origo.
Parameters
radius |
number |
Radius of the cylinder. |
height |
number |
Height of the cylinder. |
segmentation |
integer |
Segmentation number. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateCylinder (0.5, 1.0, 50, true, true);
JSM.GeneratePie
Description
Generates a pie. The center of the pie will be the origo.
Parameters
radius |
number |
Radius of the pie. |
height |
number |
Height of the pie. |
angle |
number |
Angle of the pie. |
segmentation |
integer |
Segmentation number. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GeneratePie (1.0, 0.2, 270 * JSM.DegRad, 50, true, true);
JSM.GenerateCone
Description
Generates a cone. The center of the cone will be the origo.
Parameters
topRadius |
number |
Top radius of the cone (can be 0.0). |
bottomRadius |
number |
Bottom radius of the cone (can be 0.0). |
height |
number |
Height of the the cone. |
segmentation |
integer |
Segmentation number. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateCone (0.2, 0.6, 1.0, 50, true, true);
JSM.GeneratePrism
Description
Generates a prism.
Parameters
basePolygon |
[coordinate] |
The base polygon of the prism defined by its coordinates. |
direction |
vector |
Base polygon offset direction. |
height |
number |
Height of the prism. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
Example
var basePolygon = [
new JSM.Coord (-1.0, -1.0, 0.0),
new JSM.Coord (1.0, -1.0, 0.0),
new JSM.Coord (1.0, 1.0, 0.0),
new JSM.Coord (0.0, 1.0, 0.0),
new JSM.Coord (0.0, 0.0, 0.0),
new JSM.Coord (-1.0, 0.0, 0.0)
];
var direction = new JSM.Vector (0.0, 0.0, 1.0);
var body = JSM.GeneratePrism (basePolygon, direction, 1.0, true);
JSM.GeneratePrismWithHole
Description
Generates a prism. The base polygon can contain holes. The top and bottom polygons are triangulated.
Parameters
basePolygon |
[coordinate] |
The base polygon of the prism defined by its coordinates. Hole definitions must be started with a null element, and must be in reversed orientation. |
direction |
vector |
Base polygon offset direction. |
height |
number |
Height of the prism. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
Example
var basePolygon = [
new JSM.Coord (-1.0, -1.0, 0.0),
new JSM.Coord (1.0, -1.0, 0.0),
new JSM.Coord (1.0, 1.0, 0.0),
new JSM.Coord (-1.0, 1.0, 0.0),
null,
new JSM.Coord (-0.5, 0.5, 0.0),
new JSM.Coord (0.5, 0.5, 0.0),
new JSM.Coord (0.5, -0.5, 0.0),
new JSM.Coord (-0.5, -0.5, 0.0)
];
var direction = new JSM.Vector (0.0, 0.0, 1.0);
var body = JSM.GeneratePrismWithHole (basePolygon, direction, 1.0, true);
JSM.GeneratePrismShell
Description
Generates a prism shell.
Parameters
basePolygon |
[coordinate] |
The base polygon of the prism defined by its coordinates. |
direction |
vector |
Base polygon offset direction. |
height |
number |
Height of the prism. |
width |
number |
Width of the shell. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
Example
var basePolygon = [
new JSM.Coord (-1.0, -1.0, 0.0),
new JSM.Coord (1.0, -1.0, 0.0),
new JSM.Coord (1.0, 1.0, 0.0),
new JSM.Coord (0.0, 1.0, 0.0),
new JSM.Coord (0.0, 0.0, 0.0),
new JSM.Coord (-1.0, 0.0, 0.0)
];
var direction = new JSM.Vector (0.0, 0.0, 1.0);
var body = JSM.GeneratePrismShell (basePolygon, direction, 1.0, 0.2, true);
JSM.GenerateCylinderShell
Description
Generates a cylinder shell. The center of the cylinder will be the origo.
Parameters
radius |
number |
Radius of the cylinder. |
height |
number |
Height of the cylinder. |
width |
number |
Width of the shell. |
segmentation |
integer |
Segmentation number. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateCylinderShell (0.5, 1.0, 0.1, 50, true, true);
JSM.GenerateLineShell
Description
Generates a polyline shell.
Parameters
basePolyLine |
[coordinate] |
The base polyline of the prism defined by its coordinates. |
direction |
vector |
Base polyline offset direction. |
height |
number |
Height of the prism. |
width |
number |
Width of the shell. |
withStartAndEnd |
boolean |
Start and end surfaces. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
Example
var basePolyLine = [
new JSM.Coord (-1.0, -1.0, 0.0),
new JSM.Coord (1.0, -1.0, 0.0),
new JSM.Coord (1.0, 1.0, 0.0),
new JSM.Coord (0.0, 1.0, 0.0),
new JSM.Coord (0.0, 0.0, 0.0),
new JSM.Coord (-1.0, 0.0, 0.0)
];
var direction = new JSM.Vector (0.0, 0.0, 1.0);
var body = JSM.GenerateLineShell (basePolyLine, direction, 1.0, 0.2, true, true);
JSM.GenerateTorus
Description
Generates a torus. The center of the torus will be the origo.
Parameters
outerRadius |
number |
Outer radius of the torus. |
innerRadius |
number |
Inner (cross section) radius of the torus. |
outerSegmentation |
integer |
Outer segmentation number. |
innerSegmentation |
integer |
Inner (cross section) segmentation number. |
isCurved |
boolean |
Smooth surface. |
Example
var body = JSM.GenerateTorus (1.0, 0.5, 50, 50, true);
JSM.GeneratePolyTorus
Description
Generates a torus with a polygon cross section. The center of the torus will be the origo.
Parameters
basePolygon |
[coordinate] |
The base polygon of the torus cross section. |
outerRadius |
number |
Outer radius of the torus. |
outerSegmentation |
integer |
Outer segmentation number. |
isCurved |
boolean |
Smooth surface. |
Example
var basePolygon = [
new JSM.Coord (-1.0, -1.0, 0.0),
new JSM.Coord (1.0, -1.0, 0.0),
new JSM.Coord (1.0, 1.0, 0.0),
new JSM.Coord (0.0, 1.0, 0.0),
new JSM.Coord (0.0, 0.0, 0.0),
new JSM.Coord (-1.0, 0.0, 0.0)
];
var direction = new JSM.Vector (0.0, 0.0, 1.0);
var body = JSM.GeneratePolyTorus (basePolygon, 2.0, 50, true);
JSM.GenerateRuledFromSectors
Description
Generates ruled surface between two sectors.
Parameters
aSector |
sector |
The first sector. |
bSector |
sector |
The second sector. |
lineSegmentation |
integer |
Segmentation along sectors. |
meshSegmentation |
integer |
Segmentation along surface. |
isCurved |
boolean |
Smooth surface. |
Example
var aSector = new JSM.Sector (new JSM.Coord (-1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0));
var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -1.0), new JSM.Coord (0.0, 1.0, 1.0));
var body = JSM.GenerateRuledFromSectors (aSector, bSector, 50, 50, true);
JSM.GenerateRuledFromSectorsWithHeight
Description
Generates ruled surface between two sectors, and generates a height for it.
Parameters
aSector |
sector |
The first sector. |
bSector |
sector |
The second sector. |
lineSegmentation |
integer |
Segmentation along sectors. |
meshSegmentation |
integer |
Segmentation along surface. |
isCurved |
boolean |
Smooth surface. |
isCurved |
boolean |
Smooth surface. |
height |
number |
Height. |
Example
var aSector = new JSM.Sector (new JSM.Coord (-1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0));
var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -1.0), new JSM.Coord (0.0, 1.0, 1.0));
var body = JSM.GenerateRuledFromSectorsWithHeight (aSector, bSector, 50, 50, true, 0.2);
JSM.GenerateRuledFromCoords
Description
Generates ruled surface between two coordinate array. The arrays have to contain the same number of coordinates.
Parameters
aCoords |
[coordinate] |
The first array of coords. |
bCoords |
[coordinate] |
The second array of coords. |
meshSegmentation |
integer |
Segmentation along surface. |
isCurved |
boolean |
Smooth surface. |
Example
var aCoords = [
new JSM.Coord (0.0, 0.0, 0.0),
new JSM.Coord (0.0, 1.0, 1.0),
new JSM.Coord (0.0, 2.0, 0.0),
new JSM.Coord (0.0, 3.0, 1.0),
new JSM.Coord (0.0, 4.0, 0.0)
];
var bCoords = [
new JSM.Coord (2.0, 0.0, 1.0),
new JSM.Coord (2.0, 1.0, 0.0),
new JSM.Coord (2.0, 2.0, 1.0),
new JSM.Coord (2.0, 3.0, 0.0),
new JSM.Coord (2.0, 4.0, 1.0)
];
var body = JSM.GenerateRuledFromCoords (aCoords, bCoords, 50, true);
JSM.GenerateRevolved
Description
Generates revolved surface of a polyline around an axis.
Parameters
polyLine |
[coordinate] |
The polyline to revolve. |
axis |
sector |
The axis of the revolve. |
angle |
number |
The angle of the revolve. Top and bottom surfaces generated only if this angle is 360 degree. |
segmentation |
integer |
Segmentation number. |
withTopAndBottom |
boolean |
Top and bottom surfaces. |
isCurved |
boolean |
Smooth surface. |
Example
var polyLine = [
new JSM.Coord (0.0, -1.0, -1.0),
new JSM.Coord (0.0, -0.5, 0.0),
new JSM.Coord (0.0, -1.0, 1.0)
];
var axis = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));
var body = JSM.GenerateRevolved (polyLine, axis, 360.0 * JSM.DegRad, 50, true, true);
JSM.GenerateFunctionSurface
Description
Generates the surface of a 3D function.
Parameters
function3D |
function |
The function. |
intervalMin |
coordinate |
The interval minimum of the surface. |
intervalMax |
coordinate |
The interval maximum of the surface. |
segmentation |
integer |
Segmentation number. |
isCurved |
boolean |
Smooth surface. |
Example
function TheFunction (x, y) {
return x * x - y * y;
}
var min = new JSM.Coord2D (-0.5, -0.5);
var max = new JSM.Coord2D (0.5, 0.5);
var body = JSM.GenerateFunctionSurface (TheFunction, min, max, 50, true);
JSM.GenerateFunctionSurfaceSolid
Description
Generates a cuboid with the surface of a 3D function on the top.
Parameters
function3D |
function |
The function. |
intervalMin |
coordinate |
The interval minimum of the surface. |
intervalMax |
coordinate |
The interval maximum of the surface. |
segmentation |
integer |
Segmentation number. |
isCurved |
boolean |
Smooth surface. |
bottomZ |
number |
The bottom coordinate of the surface. |
Example
function TheFunction (x, y) {
return x * x - y * y;
}
var min = new JSM.Coord2D (-0.5, -0.5);
var max = new JSM.Coord2D (0.5, 0.5);
var body = JSM.GenerateFunctionSurfaceSolid (TheFunction, min, max, 50, true, 0.5);