struct Oid::Vector2
- Oid::Vector2
- Struct
- Value
- Object
Overview
Representation of 2D vector
Included Modules
- JSON::Serializable
- Oid::Vector
Defined in:
oid/resources/vectors/vector2.crConstructors
Class Method Summary
Instance Method Summary
-
#!=(other)
Returns
true
if this object is not equal to other. -
#*(other : Vector)
Performs component multiplication (for dot product see
#dot
) -
#*(other : Float64)
Performs multiplication
-
#+(other : Vector)
Performs component addition
-
#+(other : Float64)
Performs component addition
-
#-(other : Vector)
Performs component subtraction
-
#-(other : Float64)
Performs component subtraction
-
#-
Returns negated vector
-
#/(other : Vector)
Performs component division
-
#==(other)
Returns
true
if this struct is equal to other. -
#angle(other : Vector)
Returns angle between two vectors
-
#angle
Returns direction of a vector
-
#clone
Clones this vector and passes it into a block if given
-
#cross(other)
Returns cross product of two vectors
-
#distance(other : Vector)
Finds distance between two vectors
-
#dot(other)
Returns dot product of two vectors
-
#find_normal_axis(other)
Finds normal axis between two vectors
-
#magnitude
Returns magnitude of this vector
-
#normalize!
Normalizes current vector
- #to_v3
- #to_v4
-
#values
Converts vector to a tuple of values
- #x : Float64
- #x=(x : Float64)
- #y : Float64
- #y=(y : Float64)
-
#zero!
Fills current vector with zero
Instance methods inherited from module Oid::Vector
!=(other)
!=,
%(other : Vector)
%,
*(other : Vector)*(other : Float64) *, **(other : Vector) **, +(other : Vector)
+(other : Float64) +, -(other : Vector)
- -, /(other : Vector)
/(other : Float64) /, ==(other) ==, clone
clone(&b) clone, cross(other) cross, distance(other : Vector) distance, dot(other) dot, heading heading, mag mag, magnitude magnitude, normalize normalize, normalize! normalize!, values values, zero! zero!
Constructor Detail
Class Method Detail
Instance Method Detail
Returns true
if this object is not equal to other.
By default this method is implemented as !(self == other)
so there's no need to override this unless there's a more efficient
way to do it.
Returns true
if this struct is equal to other.
Both structs' instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4
p1 == p2 # => true
p1 == p3 # => false