How To Position & Rotate
In DynaMaker position and rotation are described by vectors in the 2D or 3D space.
Position
-
A position in 2D is defined as:
const position2D = new SKYMATH.Vector2D(15, 7)An example of use in the 2D space could be placing sketches in layouts (2D containers), as:
const layout = new SKYCAD.Layout()const logoSketch = GEOM2D.getLogoSketch()layout.addSketch(logoSketch, {position: new SKYMATH.Vector2D(15, 7),}) -
A position in 3D is defined as:
const position3D = new SKYMATH.Vector3D(15, 7, 20)An example of use in the 3D space could be placing models in geometry groups (3D containers), as:
const geometryGroup = new SKYCAD.GeometryGroup()const logoModel = GEOM3D.getLogoModel()geometryGroup.addSketch(logoModel, {position: new SKYMATH.Vector3D(15, 7, 20),})
Here is an interactive app that represents how 3D position affects the placement of the model:
Rotation
In DynaMaker, rotation as a 3D vector works follows the Euler convention, which applies each coordinate of the 3D vector in order, i.e. first X, then Y, and finally Z. It is defined as:
const rotation3D = new SKYMATH.Vector3D(Math.PI / 6, 0, Math.PI / 2) // X: 30°; Y: 0°; Z: 90°
An example of use in the 3D space could be placing models in geometry groups (3D containers), as:
const geometryGroup = new SKYCAD.GeometryGroup()
const logoModel = GEOM3D.getLogoModel()
geometryGroup.addSketch(logoModel, {
rotation: new SKYMATH.Vector3D(Math.PI / 6, 0, Math.PI / 2),
})
There are cases where it is troublesome to match the orientation you are looking for following the Euler angles. There's
an easier alternative to define a rotation with optional inputs instead of a SKYMATH.Vector3D like the following:
const geometryGroup = new SKYCAD.GeometryGroup()
const logoModel = GEOM3D.getLogoModel()
geometryGroup.addGeometry(logoModel, {
rotation: {
unit: 'deg',
order: 'zyx',
x: 30,
y: 0,
z: 0,
},
})
where:
unitas'deg'or'rad'to choose which units you are using in each coordinate.orderas'xyz'(Euler angles) or'zyx'to choose which order to apply the angles of each coordinate.x,yandzas the value of each coordinate in the units given inunit.
Here is an interactive app that represents how 3D rotation (input units in degrees) affects the placement of the model following the Euler angles, which are applied in strict order: