Class: Geom::Transformation2d

Inherits:
Object
  • Object
show all

Overview

Version:

  • LayOut 2018

Class Method Summary # collapse

Instance Method Summary # collapse

Constructor Details

#initializeGeom::Transformation2d #initialize(transformation) ⇒ Geom::Transformation2d #initialize(array) ⇒ Geom::Transformation2d

The #initialize method creates a new Geom::Transformation2d. You can use this method or one of the more specific methods for creating specific kinds of Geom::Transformation2d.

Examples:

tr = Geom::Transformation2d.new({1.0, 0.0, 0.0, 1.0, 1.0, 1.0})

Overloads:

Version:

  • LayOut 2018

Class Method Details

.rotation(point, angle) ⇒ Geom::Transformation2d

The rotation method is used to create a transformation that does rotation about a point.

Examples:

point = Geom::Point2d.new(10, 5)
angle = 45.degrees # Return 45 degrees in radians.
transformation = Geom::Transformation2d.rotation(point, angle)

Parameters:

Returns:

Version:

  • LayOut 2019

.scaling(scale) ⇒ Geom::Transformation2d .scaling(xscale, yscale) ⇒ Geom::Transformation2d .scaling(point, scale) ⇒ Geom::Transformation2d .scaling(point, xscale, yscale) ⇒ Geom::Transformation2d

The scaling method is used to create a transformation that does scaling.

Examples:

point = Geom::Point3d.new(20, 30, 0)
scale = 10
tr = Geom::Transformation2d.scaling(point, scale)

Overloads:

  • .scaling(scale) ⇒ Geom::Transformation2d

    With one argument, it does a uniform scale about the origin.

    Parameters:

    • scale (Float)

      The global scale factor for the transform.

    Returns:

  • .scaling(xscale, yscale) ⇒ Geom::Transformation2d

    With two arguments, it does a non-uniform scale about the origin.

    Parameters:

    • xscale (Float)

      The scale factor in the x direction for the transform.

    • yscale (Float)

      The scale factor in the y direction for the transform.

    Returns:

  • .scaling(point, scale) ⇒ Geom::Transformation2d

    With two arguments, it does a uniform scale about an arbitrary point.

    Parameters:

    • point (Geom::Point2d)
    • scale (Float)

      The global scale factor for the transform.

    Returns:

  • .scaling(point, xscale, yscale) ⇒ Geom::Transformation2d

    With three arguments it does a non-uniform scale about an arbitrary point.

    Parameters:

    • point (Geom::Point2d)
    • xscale (Float)

      The scale factor in the x direction for the transform.

    • yscale (Float)

      The scale factor in the y direction for the transform.

    Returns:

Version:

  • LayOut 2019

.translation(vector) ⇒ Geom::Transformation2d .translation(point) ⇒ Geom::Transformation2d

The translation method is used to create a transformation that does translation.

Examples:

vector = Geom::Vector2d.new(0, 1)
tr = Geom::Transformation2d.translation(vector)

Overloads:

Version:

  • LayOut 2019

Instance Method Details

#*(point) ⇒ Geom::Point2d #*(vector) ⇒ Geom::Vector2d #*(transformation) ⇒ Geom::Transformation2d #*(point) ⇒ Array<Float, Float>

The #* method is used to do matrix multiplication using the transform.

Examples:

point1 = Geom::Point2d.new(5, 10)
point2 = Geom::Point2d.new(2, 2)
tr = Geom::Transformation2d.new(point1)
# Returns Point2d(7, 12)
point3 = tr * point2

Overloads:

Version:

  • LayOut 2019

#==(other) ⇒ Boolean

The #== method checks to see if the two Geom::Transformation2ds are equal. This checks whether the values of the transformations are the same.

Examples:

tr = Geom::Transformation2d.new({1.0, 0.0, 0.0, 1.0, 1.0, 1.0})
tr == tr.clone

Parameters:

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#cloneGeom::Transformation2d

The #clone method creates a copy of the Geom::Transformation2d.

Examples:

tr1 = Geom::Transformation2d.new
tr2 = tr1.clone

Returns:

Version:

  • LayOut 2018

#identity?Boolean

The #identity? method determines if the Geom::Transformation2d is the IDENTITY_2D transform.

Examples:

array = {1.0, 0.0, 0.0, 1.0, 1.0, 0.0}
tr = Geom::Transformation2d.new(array)
# Returns false.
status = tr.identity?
tr = Geom::Transformation2d.new
# Returns true.
status = tr.identity?
# Returns true.
status = IDENTITY_2D.identity?

Returns:

  • (Boolean)

    true if the transform is the identity

Version:

  • LayOut 2018

#inverseGeom::Transformation2d

The #inverse method is used to retrieve the inverse of a transformation.

Examples:

point = Geom::Point2d.new(5, 10)
tr1 = Geom::Transformation2d.new(point)
tr2 = tr1.inverse

Returns:

Version:

  • LayOut 2019

#invert!Geom::Transformation2d

The #invert! method sets the transformation to its inverse.

Examples:

point = Geom::Point2d.new(5, 10)
tr = Geom::Transformation2d.new(point)
tr.invert!

Returns:

Version:

  • LayOut 2019

#set!(transformation) ⇒ Geom::Transformation2d #set!(matrix) ⇒ Geom::Transformation2d

The #set! method sets the Geom::Transformation2d to match another one. The argument is anything that can be converted into a Geom::Transformation2d.

Examples:

tr1 = Geom::Transformation2d.new
array = {2.0, 0.0, 0.0, 2.0, 0.0, 0.0}
tr1.set!(array)

Overloads:

Version:

  • LayOut 2018

#to_aArray<Float>

The #to_a method returns a 6 element array which contains the values that define the Transformation2d.

Examples:

tr = Geom::Transformation2d.new
tr.to_a.each_slice(2) {|a| p a}

Returns:

  • (Array<Float>)

    an array of 6 elements

Version:

  • LayOut 2018