6.2 - Scaling¶
Scaling changes the size of a model. But it can also move a model’s location and flip models about the global axes. Mathematically, scaling is a simple multiplication.
Scaling is an afine transformation that is applied only to the vertices
of a model. A vertex is a
location in 3D space defined by its distance along 3 axes –
(x, y, z)
. Let’s use the notation (x_new, y_new, z_new)
to represent a transformed
vertex location. Uniform scaling uses a single scale factor, s
, to
change all 3 components of a vertex. In equation format,
scaling is performed like this:
x_new = x * s;
y_new = y * s;
z_new = z * s;
You can also scale using a different scale factor for each axis. Let’s call
the 3 scale factors sx
, sy
, and sz
. This is referred
to as non-uniform scaling, which is a simple multiplication like this:
x_new = x * sx;
y_new = y * sy;
z_new = z * sz;
Notice that scaling by 1 does not change an object. (Any value multiplied times 1 is itself.) Vertices are typically manipulated as a unit, so if you want to scale along one axis and leave the other axes unchanged, use a scale factor of 1 for the components you want unchanged.
Scaling by 0 is typically avoided since multiplication of any value times 0 results in 0. Given that a scaling operation is applied to every vertex of a model, scaling by 0 would make every vertex in the model become (0,0,0) and the model would degenerate to a single point at the origin – which is typically not a desirable outcome – unless you were trying to make an object disappear.
All scaling is “about the origin.” Consider a simple number line. When you multiple a number by a value greater than 1, the number moves further away from the origin. When you multiple a number by a value less than 1, the number moves closer to the origin. Either way, the value changes its location relative to the origin!
Special Cases and Effects¶
Please study and experiment with the following scaling examples.
Scaling a model that is centered at the origin shrinks or enlarges the model, but it does not change the model’s location.
An example of uniform scaling where the object is centered about the origin.
AnimateOpen this webgl demo program in a new tab or window
Scale 1.00 : 0.3 2.0
Non-uniform scaling uses three distinct scaling factors, one for each axis. The model is still centered at the origin, so its location does not change.
An example of non-uniform scaling where the object is centered about the origin.
AnimateOpen this webgl demo program in a new tab or window
X Scale 1.00 : 0.3 2.0
Y Scale 1.00 : 0.3 2.0
Z Scale 1.00 : 0.3 2.0
Scaling a model that is away from the origin shrinks or enlarges the model and also changes the model’s location. The direction of motion is determined by which quadrant the model is located. Notice that in the next example each of the eight models move in different directions, but they all move away from or towards the origin. This is another visual demonstration that all scaling is “about the origin.” Most models are centered about the origin when they are created for this very reason.
An example of scaling where the object is NOT centered about the origin.
AnimateOpen this webgl demo program in a new tab or window
Scale 1.00 : 0.3 2.0
X Scale 1.00 : 0.3 2.0
Y Scale 1.00 : 0.3 2.0
Z Scale 1.00 : 0.3 2.0
A vertex at the origin, (0,0,0), is not affected by scaling. (Zero times any scale factor is still zero.) A vertex of (0,0,0) in a model provides a convenient reference point for locating a model in a scene.
Scaling an object with a negative scale value preforms a mirror operation.
An example of scaling used to mirror an object about an axis.
AnimateOpen this webgl demo program in a new tab or window
Scale 1.00 : 0.3 2.0
Make X scale negative
Make Y scale negative scale(1.00, 1.00, 1.00)
Make Z scale negative
To negate (or undo) a scaling operation you simply need to scale a model by the reciprocal of the scaling factor. For example, if you scaled a model by a factor of 3, you can get the original model back by scaling by 1/3. (Note: You can’t undo scaling by zero. Why not?)
Glossary¶
- scale
- Change the size of a model. (All vertices move closer, or farther away, from the origin.)
- uniform scaling
- Change the size of a model by the same amount along each of the coordinate system axes. One scale factor is used.
- non-uniform scaling
- Change the size of a model but by different amounts along each of the coordinate system axes. Three scaling factors are used.
- mirror
- Flip an object 180 degrees about a coordinate system axis. The scale factor is negative.
Self Assessment¶
-
Q-121: Scaling a model requires a _____________ operation on each vertex in the model.
- multiplication
- Correct. Scaling is performed by multiplication.
- division
- Incorrect. While it is possible to produce scaling using division, division is the most expensive calculation a CPU can perform and in computer graphics divisions are avoided whenever possible.
- subtraction
- Incorrect. Subtraction (really addition) is used for translation.
- addition
- Incorrect. Addition is used for translation.
-
Q-122: Scaling changes the location of a model under what circumstances?
- When the model is not centered at the origin.
- Correct. An object away from the origin will move further away from the origin when enlarged and closer to the origin when shrunk.
- When the model is composed of only triangles.
- Incorrect. All models are composed of only triangles. This has no impact on scaling.
- When the model is centered at the origin.
- Incorrect. If the model is centered at the origin, then all vertices move the same percentage away or towards the origin, which keeps the object in the same relative location.
-
Q-123: If you want to scale the x and y dimensions of a model, but leave the z dimension unchanged,
what scale factor should you use for the z scale factor?
- 1.0
- Correct. This leave the z components of all vertices unchanged because multiplying by 1.0 does not change them.
- 0.0
- Incorrect. This makes all vertex z components be 0.0, which collapses your entire 3D model to a single plane.
- the same scale factor as the x axis
- Incorrect.
-
Q-124: Using a negative value for the X scale factor mirrors a model about which plane?
- Y-Z plane
- Correct. Since the x values become negative, the model goes on the opposite side of the Y-Z plane.
- X plane
- Incorrect. (A single axis does not define a plane.)
- X-Y plane
- Incorrect. Mirroring about the X-Y plane requires a negative z scale factor.
- X-Z plane
- Incorrect. Mirroring about the X-Z plane requires a negative y scale factor.
-
Q-125: Uniform scaling of a model by 0.0 does what to a model?
- Collapses all vertices to (0,0,0), thus losing all 3D information about the model.
- Correct.
- Performs the "unity" operation which leaves the model unchanged.
- Incorrect. (The "unity" operation uses a scale factor of 1.0.)
- Makes the model larger.
- Incorrect.
- Makes the model smaller.
- Partially correct, but there is a better answer.