123456789_123456789_123456789_123456789_123456789_

Class: Geom::Transformation2d

Relationships
Inherits: Object

Overview

Version:

  • LayOut 2018

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newTransformation2d .new(transformation) ⇒ Transformation2d .new(array) ⇒ Transformation2d

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

Examples:

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

Overloads:

  • .newTransformation2d
  • .new(transformation) ⇒ Transformation2d

    Creates a Transformation2d that is a copy of another Transformation2d. This is equivalent to #clone.

    Parameters:

    • transform (Transformation2d)
  • .new(array) ⇒ Transformation2d

    Parameters:

Version:

  • LayOut 2018

Class Method Details

.rotation(point, angle) ⇒ 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:

Version:

  • LayOut 2019

.scaling(scale) ⇒ Transformation2d .scaling(xscale, yscale) ⇒ Transformation2d .scaling(point, scale) ⇒ Transformation2d .scaling(point, xscale, yscale) ⇒ 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) ⇒ Transformation2d

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

    Parameters:

    • scale (Float)

      The global scale factor for the transform.

  • .scaling(xscale, yscale) ⇒ 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.

  • .scaling(point, scale) ⇒ 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.

  • .scaling(point, xscale, yscale) ⇒ 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.

Version:

  • LayOut 2019

.translation(vector) ⇒ Transformation2d .translation(point) ⇒ 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:

  • .translation(vector) ⇒ Transformation2d

    Parameters:

  • .translation(point) ⇒ Transformation2d

    Parameters:

Version:

  • LayOut 2019

Instance Attribute Details

#identity?Boolean (readonly)

The #identity? method determines if the 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

Instance Method Details

#*(point) ⇒ Geom::Point2d #*(vector) ⇒ Geom::Vector2d #*(transformation) ⇒ 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 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:

  • other (Transformation2d)

Version:

  • LayOut 2018

#cloneTransformation2d

The #clone method creates a copy of the Transformation2d.

Examples:

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

Version:

  • LayOut 2018

#inverseTransformation2d

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

Version:

  • LayOut 2019

#invert!Transformation2d

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

Examples:

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

Version:

  • LayOut 2019

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

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

Examples:

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

Overloads:

  • #set!(transformation) ⇒ Transformation2d

    Parameters:

    • transformation (Transformation2d)
  • #set!(matrix) ⇒ Transformation2d

    Parameters:

    • matrix (Array<Float>)

      An array of 6 floats.

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