Transforms

Transforms can be applied to two and three dimensional csg tree Items.

class pcsg.transform.Transform

Informational base class of Transform objects. This empty class is implemented for type matching purposes.

dimensions

The number of dimensions is determined from the child instance.

Translate

../_images/8f3344ee7f4e.png
../_images/fb115c2486f1.png

Transform solid on x-axis

../_images/8f3344ee7f4e.png
../_images/144d44e7b308.png

Transform solid on x- and y-axis

../_images/8f3344ee7f4e.png
../_images/38d06043ae6b.png

Transform solid by vector

../_images/aca3dc48975b.png
../_images/d5a27c7270c4.png

Transform shape by vector

Example: Transform solid on x-axis

../_images/02296cdde8fc.png
../_images/c6aa006794a7.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Translate (body, y = 2)

Example: Transform solid on x- and y-axis

../_images/02296cdde8fc.png
../_images/49560052b2a9.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Translate (body, x = 1, y = 2)

Example: Transform solid by vector

../_images/02296cdde8fc.png
../_images/7f62940466dd.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Translate (body, (1, 2, -2))

Example: Transform shape by vector

../_images/ea7b9cfc61b3.png
../_images/a2b3da992893.png
import pcsg

body = pcsg.shape.Circle (radius = 0.5)

item = pcsg.transform.Translate (body, (0.5, 1))
class pcsg.transform.Translate(children: Optional[object] = None, vector: Optional[tuple] = None, x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, name: Optional[str] = None, attributes: Optional[pcsg.attributes.Attributes] = None)

Bases: pcsg.tree.Node, pcsg.transform.Transform

Translates a Shape or Solid.

A translation can be constructed by a vector of the parameters x, y, and z.

When translating Shapes only the x and y parameters must be used, z must be 0 (default value).

children

Tuple containing a single Shape or Solid.

x

Translation in direction of the x-axis.

y

Translation in direction of the y-axis.

z

Translation in direction of the z-axis.

Scale

../_images/8f3344ee7f4e.png
../_images/9b00230d41ca.png

Scale solid on x-axis

../_images/8f3344ee7f4e.png
../_images/d6a819b71e1d.png

Scale solid on x- and y-axis

../_images/8f3344ee7f4e.png
../_images/72a21b969980.png

Scale solid by vector

../_images/aca3dc48975b.png
../_images/dba87c4c3ef6.png

Scale shape by vector

Example: Scale solid on x-axis

../_images/02296cdde8fc.png
../_images/5341204f7204.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Scale (body, sy = 2)

Example: Scale solid on x- and y-axis

../_images/02296cdde8fc.png
../_images/4acdf6d34d4c.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Scale (body, sx = 0.6, sy = 1.3)

Example: Scale solid by vector

../_images/02296cdde8fc.png
../_images/ee4ba88712e1.png
import pcsg

body = pcsg.solid.Sphere (radius = 1)

item = pcsg.transform.Scale (body, (1.7, 0.9, 1.2))

Example: Scale shape by vector

../_images/ea7b9cfc61b3.png
../_images/730c05da7821.png
import pcsg

body = pcsg.shape.Circle (radius = 0.5)

item = pcsg.transform.Scale (body, (0.5, 1))
class pcsg.transform.Scale(children: Optional[object] = None, vector: Optional[tuple] = None, sx: Optional[float] = None, sy: Optional[float] = None, sz: Optional[float] = None, name: Optional[str] = None, attributes: Optional[pcsg.attributes.Attributes] = None)

Bases: pcsg.tree.Node, pcsg.transform.Transform

Scales a Shape or Solid.

A scale can be constructed by a vector of the parameters sx, sy, and sz.

When scaling Shapes only the sx and sy parameters must be used, sz must be 1 (default value).

children

Tuple containing a single Shape or Solid.

sx

Scale in direction of the x-axis.

sy

Scale in direction of the y-axis.

sz

Scale in direction of the z-axis.

Rotate

../_images/e78789989c69.png
../_images/14d9dcf0af12.png

Rotate solid around x-axis

../_images/e78789989c69.png
../_images/b49cdce24326.png

Rotate solid around x- and y-axis

../_images/e78789989c69.png
../_images/e1bc7acbb6c9.png

Rotate solid around vector

../_images/36ac968499d2.png
../_images/ed69565a80ff.png

Rotate shape around z-axis

Example: Rotate solid around x-axis

../_images/340a1c9b0c02.png
../_images/9b87074439f1.png
import pcsg

body = pcsg.solid.Cube (size = 1)

item = pcsg.transform.Rotate (body, rx = 25)

Example: Rotate solid around x- and y-axis

../_images/340a1c9b0c02.png
../_images/2e2f4454dfab.png
import pcsg

body = pcsg.solid.Cube (size = 1)

item = pcsg.transform.Rotate (body, rx = 25, ry = 15)

Example: Rotate solid around vector

../_images/340a1c9b0c02.png
../_images/eb211e4707cb.png
import pcsg

body = pcsg.solid.Cube (size = 1)

item = pcsg.transform.Rotate (body, (10, 20, 35))

Example: Rotate shape around z-axis

../_images/69d87e89ae73.png
../_images/9c065e3e782c.png
import pcsg

body = pcsg.transform.Translate (
    pcsg.shape.Square (size = 0.5),
    x = 1
)

item = pcsg.transform.Rotate (body, rz = 30)
class pcsg.transform.Rotate(children: Optional[object] = None, vector: Optional[tuple] = None, rx: Optional[float] = None, ry: Optional[float] = None, rz: Optional[float] = None, name: Optional[str] = None, attributes: Optional[pcsg.attributes.Attributes] = None)

Bases: pcsg.tree.Node, pcsg.transform.Transform

Rotates a Shape or Solid.

A rotation can be constructed by a vector of the parameters rx, ry, and rz. The rotation applies the 3 angles by rotating around the z axis, followed by a rotation around the y axis, finally a rotation around the x axis will be applied.

When rotating Shapes only the rz parameter is allowed to use, rx and ry must be 0 (default value).

children

Tuple containing a single Shape or Solid.

rx

Rotation around the x-axis in degrees.

ry

Rotation around the y-axis in degrees.

rz

Rotation around the z-axis in degrees.