CGA Code Lesson #3 – Rotate, Size, Translate

CGA OPERATIONS COVERED

r()- rotate
s()- size
t()- translate

INTRODUCTION

The rotate r( ), size s ( ) and translate t( ) shape functions are neighbors in the alphabet and they are used with each other to manipulate scopes, the imaginary box that surrounds a shape and defines its maximum x, y and z dimensions.

It will be important to know these before we start shaping buildings and modeling facades in Tutorials 6 and 7.

Rotate: In Figure A, a flat plane is rotated 45 degrees on it’s x, y and z axes, which are indicated with blue lines. The parameters for the three planes are: x-axis r(45,0,0);   y-axis r(0,45,0);   z-axis r(0,0,45).  The planes can also be rotated in the opposite directions using negative values.

========================

Size:  Here, we will resize shapes by adjusting their scope. When we change the x, y and/or z dimensions of the scope, whatever shape is inside will change dimensions. Each primitive cone starts with 12 sides, a diameter of 20 meters and a height of 40 meters as shown in the code block. See what happens as we resize the x, y or z of each shape’s scope: Increasing x or z makes as in Cones 2 & 3 widens them in one direction. Increasing y makes Cone 4 taller. Giving z a value of 1 actually flattens Cone 5. Depending on the adjustment to the scope, the shape may have to be translated (moved) to its desired position on the landscape.

Left to right: StartCone, Cone2, Cone3, Cone4, Cone5

StartCone -->
 primitiveCone(12,20,40)
 color("#FFFF00") 

# Resize X
Cone2-->
 primitiveCone(12,20,40)
 color("#FFFF00") 
 s(70,20,20)
 
# Resize Z 
Cone3 -->
 primitiveCone(12,20,40)
 color("#FFFF00") 
 s(20,20,70)
 
# Resize Y 
Cone4 -->
 primitiveCone(12,20,40)
 color("#FFFF00") 
 s(20,80,20)

# Flatten Z
Cone5 -->
 primitiveCone(12,20,40)
 color("#FFFF00") 
 s(20,20,1))

========================

Translate:  We will move a 10×10 meter flat plane along the x, y and z axes.

  • The yellow square represents the starting coordinates of t(0,0,0).
  • Red: t(20,0,0) – movement along the x-axis
  • Green: t(0,10,0) – movement along the y-axis (straight up)
  • Blue: t(0,0,20) – movement along the z-axis

Figure C: Translating t( ) a plane on the x, y and z axes with code below

Start-->
 primitiveQuad(10,10) 
 color("#FFFF00") // Yellow
 t(0,0,0)
Start2-->
 primitiveQuad(10,10) 
 color("#FF0000") // Red
 t(20,0,0)
 
Start3-->
 primitiveQuad(10,10) 
 color("#00FF00") // Green
 t(0,10,0)
 
Start4-->
 primitiveQuad(10,10) 
 color("#0000FF") // Blue
 t(0,0,20)

Leave a Reply

Your email address will not be published. Required fields are marked *