top of page

Translate, rotate and scale 3D models

  • Peter Mortier
  • Oct 28, 2024
  • 1 min read

Updated: 6 days ago

In this example, you will learn how to translate, rotate and scale your 3D models. These basic transformations are frequently needed when generating or manipulating 3D models.


The basic transformations are available through simple methods that are available for all Mesh objects. The translate and scale functions require a vector [x, y, z] as input. Meshes will be translated using this vector, while for scaling, this vector indicates how much to scale along each axis. You can also simply provide a single value if you want to perform a uniform scaling in all directions (e.g. cube.scale(1.5)).


Rotating 3D models can be done using the rotate functions (rotate_X, rotate_Y or rotate_Z). These functions have one argument, which is the angle in degrees used for the rotation.


from hellotriangle import shapes

# create and draw a basic cube
cube = shapes.cube()
draw(cube, color = "grey")

# use the 1st cube to create a 2nd scaled and translated cube
cubeScaled = cube.scale([0.5, 1.0, 2.0]).translate([2.0, 0.0, 0.0])
draw(cubeScaled, color = "#2BB786")

# use the 1st cube to create a 3nd rotated and translated cube
cubeRotated = cube.rotate_Z(45.0).translate([0.0, 0.0, 2.0])
draw(cubeRotated, color = "#006992")


Translate, rotate and scale 3D models
Figure: Illustration of basic transformations applied to a cube (grey: initial cube, green: scaled and translated cube, blue: rotated and translated cube).

Subscribe to our newsletter

Join our email list and get updates about HelloTriangle. Unsubscribe anytime.

Thanks for submitting!

© 2024 by HelloTriangle

  • LinkedIn
bottom of page