class Draught::Vector
Constants
- NULL
Attributes
x[R]
y[R]
Public Class Methods
from_degrees_and_magnitude(degrees, magnitude)
click to toggle source
# File lib/draught/vector.rb, line 11 def self.from_degrees_and_magnitude(degrees, magnitude) radians = degrees * (Math::PI / 180) from_radians_and_magnitude(radians, magnitude) end
from_radians_and_magnitude(radians, magnitude)
click to toggle source
# File lib/draught/vector.rb, line 16 def self.from_radians_and_magnitude(radians, magnitude) x = Math.cos(radians) * magnitude y = Math.sin(radians) * magnitude new(x, y) end
from_xy(x, y)
click to toggle source
# File lib/draught/vector.rb, line 7 def self.from_xy(x, y) new(x, y) end
new(x, y)
click to toggle source
# File lib/draught/vector.rb, line 32 def initialize(x, y) @x, @y = x, y end
translation_between(point_1, point_2)
click to toggle source
# File lib/draught/vector.rb, line 26 def self.translation_between(point_1, point_2) from_xy(point_2.x - point_1.x, point_2.y - point_1.y) end
translation_to_zero(point)
click to toggle source
# File lib/draught/vector.rb, line 22 def self.translation_to_zero(point) translation_between(point, Point::ZERO) end
Public Instance Methods
==(other)
click to toggle source
# File lib/draught/vector.rb, line 36 def ==(other) other.respond_to?(:to_transform) && other.x == x && other.y == y end
to_transform()
click to toggle source
# File lib/draught/vector.rb, line 40 def to_transform @transform ||= Transformations::Affine.new( Matrix[[1, 0, x], [0, 1, y], [0, 0, 1]] ) end