struct Geometric::Vec2

Included Modules

Defined in:

geometric/object/vec2.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Comparable(Geometric::Vec2)

max(x : T) max, min(x : T) min

Constructor Detail

def self.new(x, y) #

[View source]
def self.scan(scanner, io : IO) : self #

[View source]

Class Method Detail

def self.zero #

[View source]

Instance Method Detail

def *(other) #

[View source]
def *(other : Vec2) #

[View source]
def +(other : Vec2) #

[View source]
def +(other) #

[View source]
def + #

[View source]
def -(other : Vec2) #

[View source]
def -(other) #

[View source]
def - #

[View source]
def /(other : Vec2) #

[View source]
def /(other) #

[View source]
def <=>(other : Vec2) #
Description copied from module Comparable(Geometric::Vec2)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greter than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]

[View source]
def [](index : Int) #

[View source]
def angle : Real #

[View source]
def cross(other : Vec2) : Real #

[View source]
def dot(other : Vec2) : Real #

[View source]
def inspect(io : IO) #
Description copied from struct Struct

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"

[View source]
def length : Real #

[View source]
def rotate(rad : Real) : Vec2 #

[View source]
def to_tuple #

[View source]
def x : Real #

[View source]
def x=(x : Real) #

[View source]
def y : Real #

[View source]
def y=(y : Real) #

[View source]