6.2 - Scaling

Scaling fundamentally changes the size of a model. But it can also move a model’s location and flip models. 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’, y’, z’) 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' = x * s;
y' = y * s;
z' = z * s;

It doesn’t get much simpler than that!

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' = x * sx;
y' = y * sy;
z' = 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 the following scenarios related to scaling.

  1. 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.

    Please use a browser that supports "canvas"
    Animate
    Scale 1.00 : 0.3 2.0

    Open this webgl program in a new tab or window
  2. 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.

    Please use a browser that supports "canvas"
    Animate
    Scale X 1.00 : 0.3 2.0
    Scale Y 1.00 : 0.3 2.0
    Scale Z 1.00 : 0.3 2.0

    Open this webgl program in a new tab or window
  3. 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 models that are NOT centered at the origin.

    Please use a browser that supports "canvas"
    Animate
    Scale 1.00 : 0.3 2.0

    Open this webgl program in a new tab or window
  4. 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.

  5. Scaling an object with a negative scale value preforms a mirror operation.

    An example of mirroring a model using a negative scale value.

    Please use a browser that supports "canvas"
    Animate
    Scale 1.00 : 0.3 2.0
    Make sx negative
    Make sy negative     scale(1.0, 1.0, 1.0);
    Make sz negative

    Open this webgl program in a new tab or window
  6. 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

Question-1: Scaling a model requires a _____________ operation on each vertex in the model.





Question-2: Scaling changes the location of a model under what circumstances?




Next Section - 6.3 - Translating