Transform matrix
Author: d | 2025-04-24
Collision detection in 3D; More information; Matrices and transforms. Introduction. Matrix components and the Identity matrix; Scaling the transformation matrix; Rotating the transformation matrix; Basis of the transformation matrix; Translating the transformation matrix; Putting it
Common Matrix Transformations Identity matrix. - The
The CSS -webkit-transform property enables web authors to transform an element in two-dimensional (2D) or three-dimensional (3D) space. For example, you can rotate elements, scale them, skew them, and more. Demo The -webkit-transform property accepts a list of "transform functions" as values. These transform functions have names such as scale(), rotate(), skew(), etc, which accept parameters to determine the level of transformation (for example, the angle to rotate an element).The CSS -webkit-transform property is a proprietary CSS extension that is supported by the WebKit browser engine. WebKit extensions contain the -webkit- prefix, which indicates that it belongs to the WebKit open source framework.Although the -webkit-transform property is not part of the official W3C CSS specification, it is designed to work on browsers that are powered by the WebKit browser engine, such as Apple Safari and Google Chrome. SyntaxThe syntax for the -webkit-transform property is: Where represents one of the transform functions listed below under Accepted Values.Example CodeHere's an example of usage (note that this example also includes other proprietary extensions): Accepted ValuesHere are the accepted values for the -webkit-transform property: none Specifies that no transforms should be applied to the element. This is the default value. transform function One or more of the transform functions below.Transform FunctionsHere is a list of transform functions that you can use with the -webkit-transform property. Transform Function Description matrix() Specifies a 2D transformation in the form of a transformation matrix of six values. Syntax: -webkit-transform: matrix(m11, m12, m21, m22, tX, tY) The parameters m11, m12, m21, m22 represent the elements of a 2x2 matrix in column-major order: 1,12,1 1,22,2 The parameters tX, tY represent the x and y translation elements. Example: -webkit-transform: matrix(1, 0, 0.6, 1, 250, 0); The matrix() transform function is available on the following: Safari 3.1 and later. iOS 2.0 and later. Google Chrome 1.0 and later. matrix3d() Specifies a 3D transformation as a 4 x 4 matrix. Syntax: -webkit-transform: matrix3d(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m31, m33) The parameters represent a 4x4 homogeneous matrix of 16 values in column-major order: 0,01,02,03,0 0,11,12,13,1 0,21,22,23,2 0,31,32,33,3 The matrix3d() transform function is available on the following: Safari 4.0.3 and later running on Mac OS X version 10.6 and later. iOS 2.0 and later. Google Chrome 12.0 and later. perspective() Specifies a perspective projection matrix. Syntax: -webkit-transform: perspective(depth) Where depth equals the distance, in pixels, of
javascript - Transform a 3X3 transform matrix to 4X4 matrix for css
With part component as children)scene.mergeFinalLevel(0, 2, False)ParametersNameTypeDefaultDescriptionrootsOccurrenceList0Roots occurrences for the process (will not be removed)mergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyCollapseToParentBooleanfalseIf true, final level unique merged part will replace it's parentmergePartsMerge a set of partsscene.mergeParts(partOccurrences, 2)ParametersNameTypeDefaultDescriptionpartOccurrencesOccurrenceListOccurrence of the parts to mergemergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyReturnsNameTypeDescriptionmergedOccurrencesOccurrenceListResulting merged occurrencesmergePartsByAssembliesMerge all parts under each assembly togetherscene.mergePartsByAssemblies(0, 2)ParametersNameTypeDefaultDescriptionrootsOccurrenceList0Roots occurrences for the process (will not be removed)mergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelymergePartsByMaterialsMerge a set of parts by materialsscene.mergePartsByMaterials(partOccurrences, True, 2, True)ParametersNameTypeDefaultDescriptionpartOccurrencesOccurrenceListOccurrence of the parts to mergemergeNoMaterialsBooleantrueIf true, merge all parts with no active material together, else do not merge themmergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelycombineMeshesBooleantrueIf true, explode and remerge the input parts by visible materialsReturnsNameTypeDescriptionmergedOccurrencesOccurrenceListResulting merged occurrencesmergePartsByNameMerge all parts by occurrences namesscene.mergePartsByName(0, 2)ParametersNameTypeDefaultDescriptionrootOccurrence0Root occurrence of the subtree to processmergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyapplyTransformationApply a transformation to the local matrix of an occurrencescene.applyTransformation(occurrence, matrix)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to apply the matrix onmatrixMatrix4Transformation to matrixcreateSymmetryCreate symmetries from selectionscene.createSymmetry(occurrences, plane)ParametersNameTypeDefaultDescriptionoccurrencesOccurrenceListSelection of occurrencesplaneAxisPlaneSymmetry planerotateModify the local matrix of the scene node to apply a rotationscene.rotate(occurrence, axis, angle)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to rotateaxisVector3Axis of rotationangleAngleAngle of rotationsetLocalMatrixChange the local matrix on an occurrencescene.setLocalMatrix(occurrence, matrix)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to set the local matrixmatrixMatrix4The new occurrence local matrixgetPartMeshReturn the mesh of the TesselatedShapeParametersNameTypeDefaultDescriptionpartPartThe part componentReturnsNameTypeDescriptionmeshMeshThe mesh of the tessellated shape of the partgetPartModelReturn the model of the BRepShapeParametersNameTypeDefaultDescriptionpartPartThe part componentReturnsNameTypeDescriptionmodelModelThe model of the BRep shape of the partgetPartsMeshesReturn the meshes of the TesselatedShape for each given parts if anyscene.getPartsMeshes(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe list of part componentReturnsNameTypeDescriptionmeshesMeshListThe list of mesh of the tessellated shape of each partgetPartsModelsReturn the models of the BRepShape for each given parts if anyscene.getPartsModels(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe list of part componentReturnsNameTypeDescriptionmodelsModelListThe list of models of the BRep shape of each partgetPartsTransformsReturns the transform matrix of each given partsscene.getPartsTransforms(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformReturnsNameTypeDescriptiontransformsMatrix4ListThe transform matrix of each partgetPartsTransformsIndexedReturns the transform matrix of each given parts (indexed mode)scene.getPartsTransformsIndexed(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformReturnsNameTypeDescriptionindicesIntListThe transform matrix index for each parts (0 for Identity)transformsMatrix4ListThe list of transform matrices (the first is always Identity)setPartMeshAdd a mesh to a part (create a TessellatedShape on the part)scene.setPartMesh(part, mesh)ParametersNameTypeDefaultDescriptionpartPartThe part componentmeshMeshThe mesh to add to the partsetPartModelAdd a model to a part (create a BRepShape on the part)scene.setPartModel(part, model)ParametersNameTypeDefaultDescriptionpartPartThe part componentmodelModelThe model to add to the partsetPartsTransformsSet the transform matrix of each given partsscene.setPartsTransforms(parts, transforms)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformtransformsMatrix4ListThe transform matrix of each partsetPartsTransformsIndexedSet the transform matrix of each given parts (indexed mode)scene.setPartsTransformsIndexed(parts, indices, transforms)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformindicesIntListThe transform matrix index for each partstransformsMatrix4ListThe list of transform matricesalignPivotPointToWorldRe-orient the Pivot Point straight to world origin (the grid)scene.alignPivotPointToWorld(occurrences, False)ParametersNameTypeDefaultDescriptionoccurrencesOccurrenceListThe occurrences to modifyapplyToChildrenBoolFalseIf True, all the pivot of the descending occurrences from occurrence will be affectedmovePivotPointToOccurrenceCenterMove the pivotHelp with a matrix transformation
SyntaxDescription The watershed transform finds "catchment basins" or "watershed ridge lines" in an image by treating it as a surface where light pixels represent high elevations and dark pixels represent low elevations. The watershed transform can be used to segment contiguous regions of interest into distinct objects. L = watershed(A) returns a label matrix L that identifies the watershed regions of the input matrix A.exampleL = watershed(A,conn) specifies the connectivity to be used in the watershed computation.Examplescollapse allCompute Watershed Transform and Display Resulting Label MatrixCreate a binary image containing two overlapping circular objects. Display the image.center1 = -40;center2 = -center1;dist = sqrt(2*(2*center1)^2);radius = dist/2 * 1.4;lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)];[x,y] = meshgrid(lims(1):lims(2));bw1 = sqrt((x-center1).^2 + (y-center1).^2) 'Binary Image with Overlapping Objects')Calculate the distance transform of the complement of the binary image. The value of each pixel in the output image is the distance between that pixel and the nearest nonzero pixel of bw.D = bwdist(~bw);imshow(D,[])title('Distance Transform of Binary Image')Take the complement of the distance transformed image so that light pixels represent high elevations and dark pixels represent low elevations for the watershed transform.D = -D;imshow(D,[])title('Complement of Distance Transform')Calculate the watershed transform. Set pixels that are outside the ROI to 0.L = watershed(D);L(~bw) = 0;Display the resulting label matrix as an RGB image.rgb = label2rgb(L,'jet',[.5 .5 .5]);imshow(rgb)title('Watershed Transform')Compute Watershed Transform of 3-D Binary ImageMake a 3-D binary image containing two overlapping spheres. center1 = -10;center2 = -center1;dist = sqrt(3*(2*center1)^2);radius = dist/2 * 1.4;lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)];[x,y,z] = meshgrid(lims(1):lims(2));bw1 = sqrt((x-center1).^2 + (y-center1).^2. Collision detection in 3D; More information; Matrices and transforms. Introduction. Matrix components and the Identity matrix; Scaling the transformation matrix; Rotating the transformation matrix; Basis of the transformation matrix; Translating the transformation matrix; Putting itThe geometry of matrix transformations
Struct in UnityEngine/Implemented in:UnityEngine.CoreModuleSuggest a changeSuccess!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.CloseSubmission failedFor some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.CloseYour nameYour emailSuggestion*CancelDescriptionA standard 4x4 transformation matrix.A transformation matrix can perform arbitrary linear 3D transformations (i.e. translation, rotation, scale, shear etc.)and perspective transformations using homogenous coordinates. You rarely use matrices in scripts; mostoften using Vector3s, Quaternions and functionality of Transform class is more straightforward. Plain matrices are used in special caseslike setting up nonstandard camera projection.In Unity, several Transform, Camera, Material, Graphics and GL functions use Matrix4x4.Matrices in Unity are column major; i.e. the position of a transformation matrix is in the last column,and the first three columns contain x, y, and z-axes. Data is accessed as:row + (column*4). Matrices can beindexed like 2D arrays but note that in an expression like mat[a, b], a refers to the row index, while b refersto the column index.using UnityEngine;public class ExampleScript : MonoBehaviour{ void Start() { // get matrix from the Transform var matrix = transform.localToWorldMatrix; // get position from the last column var position = new Vector3(matrix[0,3], matrix[1,3], matrix[2,3]); Debug.Log("Transform position from matrix is: " + position); }}Static PropertiesidentityReturns the identity matrix (Read Only).zeroReturns a matrix with all elements set to zero (Read Only).PropertiesdecomposeProjectionThis property takes a projection matrix and returns the six plane coordinates that define a projection frustum.determinantThe determinant of the matrix. (Read Only)inverseThe inverse of this matrix. (Read Only)isIdentityChecks whether this is an identity matrix. (Read Only)lossyScaleAttempts to get a scale value from the matrix. (Read Only)rotationAttempts to get a rotation quaternion from this matrix.this[int,int]Access element at [row, column].transposeReturns the transpose of this matrix (Read Only).Public MethodsGetColumnGet a column of the matrix.GetRowReturns a row of the matrix.MultiplyPointTransforms a position by this matrix (generic).MultiplyPoint3x4Transforms a position by this matrix (fast).MultiplyVectorTransforms a direction by this matrix.SetColumnSets a column of the matrix.SetRowSets a row of the matrix.SetTRSSets this matrix to a translation, rotation and scaling matrix.ToStringReturns a formatted string for this matrix.TransformPlaneReturns a plane that is transformed in space.ValidTRSChecks if this matrix is a valid transform matrix.Static MethodsFrustumThis function returns a projection matrix with viewing frustum that has a near plane defined by the coordinates that were passed in.Inverse3DAffineComputes the inverse of a 3D affine matrix.LookAtCreate a "look at" matrix.OrthoCreate an orthogonal projection matrix.PerspectiveCreate a perspective projection matrix.RotateCreates a rotation matrix.ScaleCreates a scaling matrix.TranslateCreates a translation matrix.TRSCreates a translation, rotation and scaling matrix.OperatorsDid you find this page useful? Please give it a rating:Average transformation matrix for a list of transformations
2D transformstranslate()rotate()scale()skewX()skewY()skew()matrix()3D transformsThe rotate functionTransform PropertiesFAQsWhat are 2D and 3D transforms? What types of transformations can be applied in 2D space?What types of transformations can be applied in 3D space? How are 2D and 3D transforms implemented in computer graphics? What are some practical applications of 2D and 3D transforms?As we know, in CSS, we can do every type of decoration or design to an element. Sometimes we have to decorate an element by its shape, size, and position. There we can use the transformation property. In 2D transformation, an element can be arranged along with its X-axis and Y-axis. There are six main types of transformation.translate()rotate()scale()skewX()skew()matrix()translate()When we need to move an element along with its X-axis and Y-axis from its actual position then we use translate().Ex-2D Transform.trans {font-size: 35px;margin: 10px 0;margin-left: 80px;}img {border: 1px solid black;transition-duration: 2s;-webkit-transition-duration: 2s;}img:hover {transform: translate(100px, 100px);/* prefix for IE 9 */-ms-transform: translate(100px, 100px);/* prefix for Safari and Chrome */-webkit-transform: translate(100px, 100px);}Translate() Method“ />rotate()This is used to rotate an element clockwise or anti-clockwise along with the degree value as per our requirements.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: rotate(20deg);/* Safari */-webkit-transform: rotate(20deg);/* Standard syntax */transform: rotate(20deg);}.transs {font-size: 25px;text-align: center;margin-top: 100px;}Rotation() Method“ />scale()When we need to increase or decrease the size of an element, then we use this property. Because sometimes, the real image size can’t fit as per the height and width. So we have to change the size as per height and width.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: scale(1, 2);/* Safari */-webkit-transform: scale(1, 1);/* Standard syntax */transform: scale(1, 2);}.transss {font-size: 25px;text-align: center;margin-top: 100px;}Scale() Method“ />skewX()This method is used to skew an element. It happens on X-axis.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skewX(20deg);/* Safari */-webkit-transform: skewX(20deg);/* Standard syntax */transform: skewX(20deg);}.tranns {font-size: 25px;text-align: center;margin-top: 100px;}skewX() Method“ />skewY()This method is used to skew an element. It happens on Y-axis.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skewY(20deg);/* Safari */-webkit-transform: skewY(20deg);/* Standard syntax */transform: skewY(20deg);}.ttrans {font-size: 25px;text-align: center;margin-top: 100px;}skewY() Methodskew()This method skews an element in both X-axis and the Y-axis. The degree value can be the same or different as per our requirements.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skew(20deg, 10deg);/* Safari */-webkit-transform: skew(20deg, 10deg);/* Standard syntax */transform: skew(20deg, 10deg);}.transform {font-size: 25px;text-align: center;margin-top: 100px;}skew() Method“ />matrix()It is used when we need to use all the methods of 2D transformation properties in a single page. We can take all six properties here like matrix(scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() ).Let’s take en example –Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: matrix(1, -0.3, 0, 1, 0, 0);/* Safari */-webkit-transform: matrix(1, -0.3, 0, 1, 0, 0);/* Standard syntax */transform: matrix(1, -0.3, 0,Matrix‐Based Transforms and The Wavelet Transform
Need to create lets you define the position of a node when its transform attributes are zeroed out reduces computational overhead and simplifies editing in the node editor Currently in Maya, most constraint computation is matrix math, the result of which is decomposed to scale, rotation, and translation values that are then used to drive other transforms. This leads to extra complexity in the graph and excessive computation. The offsetParentMatrix is inserted in the transform model after the parent matrix and acts as an offset to its own parent matrix. This new attribute lets you skip the expensive decomposition/composition step. It has the added benefit of leaving the driven transform’s scale, rotation, and translation channels available for animation. This process reduces the number of DAG and DG nodes riggers need to create in rigs. Transform Offset Parent Matrix Matrix operators New Utility nodes Two new utility nodes, uvPin and proximityPin, have been created to allow transforms to follow geometry. These nodes offer better performance than the follicle or pointOnPoly constraints they replace and give you more control over how a transform can follow a surface. Rivet command A new Rivet command offers a one-step way to leverage the power of the new matrix-driven transforms together with the uvPin node. Use Rivet to create locators that attach directly to a deforming mesh. Rivet uses pinUV, with predefined settings to give you a simple way to attach things like a prop to a character, such as sticking a button on a shirt,. Collision detection in 3D; More information; Matrices and transforms. Introduction. Matrix components and the Identity matrix; Scaling the transformation matrix; Rotating the transformation matrix; Basis of the transformation matrix; Translating the transformation matrix; Putting it Scaling the transformation matrix; Rotating the transformation matrix; Basis of the transformation matrix; Translating the transformation matrix; Putting it all together; Shearing theComments
The CSS -webkit-transform property enables web authors to transform an element in two-dimensional (2D) or three-dimensional (3D) space. For example, you can rotate elements, scale them, skew them, and more. Demo The -webkit-transform property accepts a list of "transform functions" as values. These transform functions have names such as scale(), rotate(), skew(), etc, which accept parameters to determine the level of transformation (for example, the angle to rotate an element).The CSS -webkit-transform property is a proprietary CSS extension that is supported by the WebKit browser engine. WebKit extensions contain the -webkit- prefix, which indicates that it belongs to the WebKit open source framework.Although the -webkit-transform property is not part of the official W3C CSS specification, it is designed to work on browsers that are powered by the WebKit browser engine, such as Apple Safari and Google Chrome. SyntaxThe syntax for the -webkit-transform property is: Where represents one of the transform functions listed below under Accepted Values.Example CodeHere's an example of usage (note that this example also includes other proprietary extensions): Accepted ValuesHere are the accepted values for the -webkit-transform property: none Specifies that no transforms should be applied to the element. This is the default value. transform function One or more of the transform functions below.Transform FunctionsHere is a list of transform functions that you can use with the -webkit-transform property. Transform Function Description matrix() Specifies a 2D transformation in the form of a transformation matrix of six values. Syntax: -webkit-transform: matrix(m11, m12, m21, m22, tX, tY) The parameters m11, m12, m21, m22 represent the elements of a 2x2 matrix in column-major order: 1,12,1 1,22,2 The parameters tX, tY represent the x and y translation elements. Example: -webkit-transform: matrix(1, 0, 0.6, 1, 250, 0); The matrix() transform function is available on the following: Safari 3.1 and later. iOS 2.0 and later. Google Chrome 1.0 and later. matrix3d() Specifies a 3D transformation as a 4 x 4 matrix. Syntax: -webkit-transform: matrix3d(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m31, m33) The parameters represent a 4x4 homogeneous matrix of 16 values in column-major order: 0,01,02,03,0 0,11,12,13,1 0,21,22,23,2 0,31,32,33,3 The matrix3d() transform function is available on the following: Safari 4.0.3 and later running on Mac OS X version 10.6 and later. iOS 2.0 and later. Google Chrome 12.0 and later. perspective() Specifies a perspective projection matrix. Syntax: -webkit-transform: perspective(depth) Where depth equals the distance, in pixels, of
2025-04-18With part component as children)scene.mergeFinalLevel(0, 2, False)ParametersNameTypeDefaultDescriptionrootsOccurrenceList0Roots occurrences for the process (will not be removed)mergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyCollapseToParentBooleanfalseIf true, final level unique merged part will replace it's parentmergePartsMerge a set of partsscene.mergeParts(partOccurrences, 2)ParametersNameTypeDefaultDescriptionpartOccurrencesOccurrenceListOccurrence of the parts to mergemergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyReturnsNameTypeDescriptionmergedOccurrencesOccurrenceListResulting merged occurrencesmergePartsByAssembliesMerge all parts under each assembly togetherscene.mergePartsByAssemblies(0, 2)ParametersNameTypeDefaultDescriptionrootsOccurrenceList0Roots occurrences for the process (will not be removed)mergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelymergePartsByMaterialsMerge a set of parts by materialsscene.mergePartsByMaterials(partOccurrences, True, 2, True)ParametersNameTypeDefaultDescriptionpartOccurrencesOccurrenceListOccurrence of the parts to mergemergeNoMaterialsBooleantrueIf true, merge all parts with no active material together, else do not merge themmergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelycombineMeshesBooleantrueIf true, explode and remerge the input parts by visible materialsReturnsNameTypeDescriptionmergedOccurrencesOccurrenceListResulting merged occurrencesmergePartsByNameMerge all parts by occurrences namesscene.mergePartsByName(0, 2)ParametersNameTypeDefaultDescriptionrootOccurrence0Root occurrence of the subtree to processmergeHiddenPartsModeMergeHiddenPartsMode2Hidden parts handling mode, Destroy them, make visible or merge separatelyapplyTransformationApply a transformation to the local matrix of an occurrencescene.applyTransformation(occurrence, matrix)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to apply the matrix onmatrixMatrix4Transformation to matrixcreateSymmetryCreate symmetries from selectionscene.createSymmetry(occurrences, plane)ParametersNameTypeDefaultDescriptionoccurrencesOccurrenceListSelection of occurrencesplaneAxisPlaneSymmetry planerotateModify the local matrix of the scene node to apply a rotationscene.rotate(occurrence, axis, angle)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to rotateaxisVector3Axis of rotationangleAngleAngle of rotationsetLocalMatrixChange the local matrix on an occurrencescene.setLocalMatrix(occurrence, matrix)ParametersNameTypeDefaultDescriptionoccurrenceOccurrenceOccurrence to set the local matrixmatrixMatrix4The new occurrence local matrixgetPartMeshReturn the mesh of the TesselatedShapeParametersNameTypeDefaultDescriptionpartPartThe part componentReturnsNameTypeDescriptionmeshMeshThe mesh of the tessellated shape of the partgetPartModelReturn the model of the BRepShapeParametersNameTypeDefaultDescriptionpartPartThe part componentReturnsNameTypeDescriptionmodelModelThe model of the BRep shape of the partgetPartsMeshesReturn the meshes of the TesselatedShape for each given parts if anyscene.getPartsMeshes(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe list of part componentReturnsNameTypeDescriptionmeshesMeshListThe list of mesh of the tessellated shape of each partgetPartsModelsReturn the models of the BRepShape for each given parts if anyscene.getPartsModels(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe list of part componentReturnsNameTypeDescriptionmodelsModelListThe list of models of the BRep shape of each partgetPartsTransformsReturns the transform matrix of each given partsscene.getPartsTransforms(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformReturnsNameTypeDescriptiontransformsMatrix4ListThe transform matrix of each partgetPartsTransformsIndexedReturns the transform matrix of each given parts (indexed mode)scene.getPartsTransformsIndexed(parts)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformReturnsNameTypeDescriptionindicesIntListThe transform matrix index for each parts (0 for Identity)transformsMatrix4ListThe list of transform matrices (the first is always Identity)setPartMeshAdd a mesh to a part (create a TessellatedShape on the part)scene.setPartMesh(part, mesh)ParametersNameTypeDefaultDescriptionpartPartThe part componentmeshMeshThe mesh to add to the partsetPartModelAdd a model to a part (create a BRepShape on the part)scene.setPartModel(part, model)ParametersNameTypeDefaultDescriptionpartPartThe part componentmodelModelThe model to add to the partsetPartsTransformsSet the transform matrix of each given partsscene.setPartsTransforms(parts, transforms)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformtransformsMatrix4ListThe transform matrix of each partsetPartsTransformsIndexedSet the transform matrix of each given parts (indexed mode)scene.setPartsTransformsIndexed(parts, indices, transforms)ParametersNameTypeDefaultDescriptionpartsPartListThe parts to retrieve transformindicesIntListThe transform matrix index for each partstransformsMatrix4ListThe list of transform matricesalignPivotPointToWorldRe-orient the Pivot Point straight to world origin (the grid)scene.alignPivotPointToWorld(occurrences, False)ParametersNameTypeDefaultDescriptionoccurrencesOccurrenceListThe occurrences to modifyapplyToChildrenBoolFalseIf True, all the pivot of the descending occurrences from occurrence will be affectedmovePivotPointToOccurrenceCenterMove the pivot
2025-04-02Struct in UnityEngine/Implemented in:UnityEngine.CoreModuleSuggest a changeSuccess!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.CloseSubmission failedFor some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.CloseYour nameYour emailSuggestion*CancelDescriptionA standard 4x4 transformation matrix.A transformation matrix can perform arbitrary linear 3D transformations (i.e. translation, rotation, scale, shear etc.)and perspective transformations using homogenous coordinates. You rarely use matrices in scripts; mostoften using Vector3s, Quaternions and functionality of Transform class is more straightforward. Plain matrices are used in special caseslike setting up nonstandard camera projection.In Unity, several Transform, Camera, Material, Graphics and GL functions use Matrix4x4.Matrices in Unity are column major; i.e. the position of a transformation matrix is in the last column,and the first three columns contain x, y, and z-axes. Data is accessed as:row + (column*4). Matrices can beindexed like 2D arrays but note that in an expression like mat[a, b], a refers to the row index, while b refersto the column index.using UnityEngine;public class ExampleScript : MonoBehaviour{ void Start() { // get matrix from the Transform var matrix = transform.localToWorldMatrix; // get position from the last column var position = new Vector3(matrix[0,3], matrix[1,3], matrix[2,3]); Debug.Log("Transform position from matrix is: " + position); }}Static PropertiesidentityReturns the identity matrix (Read Only).zeroReturns a matrix with all elements set to zero (Read Only).PropertiesdecomposeProjectionThis property takes a projection matrix and returns the six plane coordinates that define a projection frustum.determinantThe determinant of the matrix. (Read Only)inverseThe inverse of this matrix. (Read Only)isIdentityChecks whether this is an identity matrix. (Read Only)lossyScaleAttempts to get a scale value from the matrix. (Read Only)rotationAttempts to get a rotation quaternion from this matrix.this[int,int]Access element at [row, column].transposeReturns the transpose of this matrix (Read Only).Public MethodsGetColumnGet a column of the matrix.GetRowReturns a row of the matrix.MultiplyPointTransforms a position by this matrix (generic).MultiplyPoint3x4Transforms a position by this matrix (fast).MultiplyVectorTransforms a direction by this matrix.SetColumnSets a column of the matrix.SetRowSets a row of the matrix.SetTRSSets this matrix to a translation, rotation and scaling matrix.ToStringReturns a formatted string for this matrix.TransformPlaneReturns a plane that is transformed in space.ValidTRSChecks if this matrix is a valid transform matrix.Static MethodsFrustumThis function returns a projection matrix with viewing frustum that has a near plane defined by the coordinates that were passed in.Inverse3DAffineComputes the inverse of a 3D affine matrix.LookAtCreate a "look at" matrix.OrthoCreate an orthogonal projection matrix.PerspectiveCreate a perspective projection matrix.RotateCreates a rotation matrix.ScaleCreates a scaling matrix.TranslateCreates a translation matrix.TRSCreates a translation, rotation and scaling matrix.OperatorsDid you find this page useful? Please give it a rating:
2025-04-142D transformstranslate()rotate()scale()skewX()skewY()skew()matrix()3D transformsThe rotate functionTransform PropertiesFAQsWhat are 2D and 3D transforms? What types of transformations can be applied in 2D space?What types of transformations can be applied in 3D space? How are 2D and 3D transforms implemented in computer graphics? What are some practical applications of 2D and 3D transforms?As we know, in CSS, we can do every type of decoration or design to an element. Sometimes we have to decorate an element by its shape, size, and position. There we can use the transformation property. In 2D transformation, an element can be arranged along with its X-axis and Y-axis. There are six main types of transformation.translate()rotate()scale()skewX()skew()matrix()translate()When we need to move an element along with its X-axis and Y-axis from its actual position then we use translate().Ex-2D Transform.trans {font-size: 35px;margin: 10px 0;margin-left: 80px;}img {border: 1px solid black;transition-duration: 2s;-webkit-transition-duration: 2s;}img:hover {transform: translate(100px, 100px);/* prefix for IE 9 */-ms-transform: translate(100px, 100px);/* prefix for Safari and Chrome */-webkit-transform: translate(100px, 100px);}Translate() Method“ />rotate()This is used to rotate an element clockwise or anti-clockwise along with the degree value as per our requirements.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: rotate(20deg);/* Safari */-webkit-transform: rotate(20deg);/* Standard syntax */transform: rotate(20deg);}.transs {font-size: 25px;text-align: center;margin-top: 100px;}Rotation() Method“ />scale()When we need to increase or decrease the size of an element, then we use this property. Because sometimes, the real image size can’t fit as per the height and width. So we have to change the size as per height and width.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: scale(1, 2);/* Safari */-webkit-transform: scale(1, 1);/* Standard syntax */transform: scale(1, 2);}.transss {font-size: 25px;text-align: center;margin-top: 100px;}Scale() Method“ />skewX()This method is used to skew an element. It happens on X-axis.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skewX(20deg);/* Safari */-webkit-transform: skewX(20deg);/* Standard syntax */transform: skewX(20deg);}.tranns {font-size: 25px;text-align: center;margin-top: 100px;}skewX() Method“ />skewY()This method is used to skew an element. It happens on Y-axis.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skewY(20deg);/* Safari */-webkit-transform: skewY(20deg);/* Standard syntax */transform: skewY(20deg);}.ttrans {font-size: 25px;text-align: center;margin-top: 100px;}skewY() Methodskew()This method skews an element in both X-axis and the Y-axis. The degree value can be the same or different as per our requirements.Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: skew(20deg, 10deg);/* Safari */-webkit-transform: skew(20deg, 10deg);/* Standard syntax */transform: skew(20deg, 10deg);}.transform {font-size: 25px;text-align: center;margin-top: 100px;}skew() Method“ />matrix()It is used when we need to use all the methods of 2D transformation properties in a single page. We can take all six properties here like matrix(scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() ).Let’s take en example –Ex-2D Transformimg {border: 1px solid black;}img:hover {/* IE 9 */-ms-transform: matrix(1, -0.3, 0, 1, 0, 0);/* Safari */-webkit-transform: matrix(1, -0.3, 0, 1, 0, 0);/* Standard syntax */transform: matrix(1, -0.3, 0,
2025-04-24