Scale

class compas.geometry.Scale(matrix=None)[source]

Bases: compas.geometry.transformations.transformation.Transformation

Creates a scale transformation.

Parameters

matrix (4x4 matrix-like, optional) – A 4x4 matrix (or similar) representing a scaling.

Raises

ValueError – If the default constructor is used, and the provided transformation matrix is not a scale matrix.

Examples

>>> S = Scale.from_factors([1, 2, 3])
>>> S[0, 0] == 1
True
>>> S[1, 1] == 2
True
>>> S[2, 2] == 3
True
>>> point = Point(2, 5, 0)
>>> frame = Frame(point, (1, 0, 0), (0, 1, 0))
>>> points = [point, Point(2, 10, 0)]
>>> S = Scale.from_factors([2.] * 3, frame)
>>> [p.transformed(S) for p in points]
[Point(2.000, 5.000, 0.000), Point(2.000, 15.000, 0.000)]

Methods

concatenate(other)

Concatenate another transformation to this transformation.

concatenated(other)

Concatenate two transformations into one Transformation.

copy()

Returns a copy of the transformation.

decomposed()

Decompose the Transformation into its Scale, Shear, Rotation, Translation and Projection components.

from_change_of_basis(frame_from, frame_to)

Computes a change of basis transformation between two frames.

from_data(data)

Creates a Transformation from a data dict.

from_euler_angles(euler_angles[, static, …])

Construct a transformation from a rotation represented by Euler angles.

from_factors(factors[, frame])

Construct a scale transformation from scale factors.

from_frame(frame)

Computes a transformation from world XY to frame.

from_frame_to_frame(frame_from, frame_to)

Computes a transformation between two frames.

from_json(filepath)

Construct an object from serialized data contained in a JSON file.

from_list(numbers)

Creates a Transformation from a list of 16 numbers.

from_matrix(matrix)

Creates a Transformation from a 4x4 matrix-like object.

inverse()

Returns the inverse transformation.

invert()

Invert this transformation.

inverted()

Returns the inverse transformation.

to_data()

Convert a Transformation object to a data dict.

to_json(filepath[, pretty])

Serialize the data representation of an object to a JSON file.

transpose()

Transpose the matrix of this transformation.

transposed()

Create a transposed copy of this transformation.

validate_data()

Validate the data of this object against its data schema (self.DATASCHEMA).

validate_json()

Validate the data loaded from a JSON representation of the data of this object against its data schema (self.DATASCHEMA).