({{, (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[{(Subscript[s, x]),(Subscript[s, y]),…}] 
gives the matrix corresponding to scaling by a factor (Subscript[s, i]) along each coordinate axis.}, {, (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[s,v]
gives the matrix corresponding to scaling by a factor s along the direction of the vector v.}})

OpenersNotesSection(Spacer1)Details

(RefLink[ScalingMatrix, paclet:ref/ScalingMatrix]) gives matrices for scaling from the origin.

(RefLink[ScalingMatrix, paclet:ref/ScalingMatrix]) works in any number of dimensions.

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Scaling by factors a, b, and c along the x, y, and z directions:

ScalingMatrix[{a,b,c}]//MatrixForm

% . {1,1,1}

Scaling by a factor s along the direction of the vector {1,-1}:

ScalingMatrix[s,{1,-1}]//MatrixForm

% . {1,-1}//Together

OpenersExampleSection1(Spacer1)Scope  (3)

Scaling factors can be negative or zero:

ScalingMatrix[{1,1,-1}]

ScalingMatrix[{1,1,1}]

Transformation applied to a 2D shape:

gr={Rectangle[],AbsolutePointSize[10],Opacity[1],{Magenta,Point[{0,0}]},{Green,Point[{1,1}]}};

Graphics[{{Opacity[.35],Blue,gr},GeometricTransformation[{Opacity[.85],Red,gr},ScalingMatrix[{1.25,.75}]]}]

Transformation applied to a 3D shape:

gr={Cuboid[],AbsolutePointSize[10],Opacity[1],{Magenta,Point[{0,0,0}]},{Green,Point[{1,1,1}]}};

Graphics3D[{{Opacity[.35],Blue,gr},GeometricTransformation[{Opacity[.85],Red,gr},ScalingMatrix[{1.25,1.5,.5}]]},Boxed->False]

OpenersExampleSection3(Spacer1)Applications  (4)

Create an ellipsoid:

Graphics3D[GeometricTransformation[Sphere[],
ScalingMatrix[{2,1.5,1}]],
Boxed->False]

Display projection of a 3D graphic:

Plot3D[Sin[x y]+1,{x,0,Pi},{y,0,Pi},Mesh->3]/.gc_GraphicsComplex:>{gc,GeometricTransformation[gc,ScalingMatrix[#]]&/@(1+10^-3-IdentityMatrix[3])}

Transform a grayscale image by scaling with a factor of 1/2:

ImageForwardTransformation[,1/2ScalingMatrix[{1,1}].#&]

A pure rescaling of a 3D image:

ImageTransformation[,(3/2)ScalingMatrix[{1,1,1}].#&]

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

The determinant of (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[s,v] is s:

Det[ ScalingMatrix[s, {1,1}]]

The inverse of (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[s,v] is given by (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[1/s,v]:

ScalingMatrix[s,{1,1}].ScalingMatrix[1/s,{1,1}]//Simplify

The determinant of (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[{(Subscript[s, 1]),…,(Subscript[s, n])}] is given by (Subscript[s, 1])⋯ (Subscript[s, n]):

Det[ ScalingMatrix[{s1,s2,s3}]]

The inverse of (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[{(Subscript[s, 1]),…,(Subscript[s, n])}] is given by (RefLink[ScalingMatrix, paclet:ref/ScalingMatrix])[{1/(Subscript[s, 1]),…,1/(Subscript[s, n])}]:

ScalingMatrix[{s1,s2,s3}].ScalingMatrix[1/{s1,s2,s3}]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Repeated scalings in different directions:

Graphics[FoldList[GeometricTransformation[#,ScalingMatrix[.75,#2]]&,Circle[],Table[{Cos[u],Sin[u]},{u,0,2Pi,2Pi/25.}]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ScalingTransform, paclet:ref/ScalingTransform])  ▪  (RefLink[Scale, paclet:ref/Scale])  ▪  (RefLink[Magnify, paclet:ref/Magnify])  ▪  (RefLink[RotationMatrix, paclet:ref/RotationMatrix])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Constructing Matrices, paclet:tutorial/ConstructingMatrices])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Geometric Transforms, paclet:guide/GeometricTransforms])}, {▪(RefLinkPlain[Constructing Matrices, paclet:guide/ConstructingMatrices])}})}})