EasyGeometry::D2::Vector
A vector in a 2-dimensional Euclidean space.
#==(vector)
Parameters:
vector - EasyGeometry::D2::Vector
Returns:
boolean (true or false)
Errors:v1 = EasyGeometry::D2::Vector.new(0, 0)
v2 = EasyGeometry::D2::Vector.new(1, 1)
v1 == v1 # true
v2 == v1 # false#-(vector)
Parameters:
vector - EasyGeometry::D2::Vector
Returns:
EasyGeometry::D2::Vector
Errors:
raise TypeError if point is not a Vectorv1 = EasyGeometry::D2::Vector.new(0, 0)
v2 = EasyGeometry::D2::Vector.new(1, 1)
v1 - v2 # Vector(-1, -1)#orthogonal_direction
Parameters:
Returns:
EasyGeometry::D2::Vector
Errors:v1 = EasyGeometry::D2::Vector.new(0, 0)
v2 = EasyGeometry::D2::Vector.new(1, 1)
v1.orthogonal_direction # Vector(1, 0)
v2.orthogonal_direction # Vector(-1, 1)#cross_product(vector)
Parameters:
vector - EasyGeometry::D2::Vector
Returns:
Numeric
Errors:
raise TypeError if point is not a Vectorv1 = EasyGeometry::D2::Vector.new(0, 0)
v2 = EasyGeometry::D2::Vector.new(1, 1)
v1.cross_product(v2) # 0#dot(vector)
Parameters:
vector - EasyGeometry::D2::Vector
Returns:
Numeric
Errors:
raise TypeError if point is not a Vectorv1 = EasyGeometry::D2::Vector.new(0, 0)
v2 = EasyGeometry::D2::Vector.new(1, 1)
v3 = EasyGeometry::D2::Vector.new(2, 2)
v1.dot(v2) # 0
v2.dot(v4) # 4#to_point
Last updated