class Vissen::Output::Point

Points are simple two dimensional coordinates with an x and y component. They are used by the `CloudContext` to keep track of the position of its points.

Attributes

position[R]

@return [Array<Float>] an array containing the x and y coordinates of

the point.
to_a[R]

@return [Array<Float>] an array containing the x and y coordinates of

the point.

Public Class Methods

from(obj, **args) click to toggle source

Coerce objects into points.

@param obj [#to_a] the object to be coerced into a `Point`. @param args (see initialize) @return [Point] a new `Point` object.

# File lib/vissen/output/point.rb, line 51
def from(obj, **args)
  new(*obj.to_a, **args)
end
new(x, y, scale: 1.0) click to toggle source

@param x [Numeric] the x coordinate of the point. @param y [Numeric] the y coordinate of the point. @param scale [Numeric] a scale factor to apply to the coordinates.

# File lib/vissen/output/point.rb, line 18
def initialize(x, y, scale: 1.0)
  @position = [x * scale, y * scale]
end

Public Instance Methods

freeze() click to toggle source

Prevents the position from being changed.

@return [self]

Calls superclass method
# File lib/vissen/output/point.rb, line 35
def freeze
  @position.freeze
  super
end
inspect() click to toggle source

@return [String] a string representation of the point.

# File lib/vissen/output/point.rb, line 41
def inspect
  format('(%0.2f,%0.2f)', *@position)
end
x() click to toggle source

@return [Float] the x coordinate of the point.

# File lib/vissen/output/point.rb, line 23
def x
  @position[0]
end
y() click to toggle source

@return [Float] the y coordinate of the point.

# File lib/vissen/output/point.rb, line 28
def y
  @position[1]
end