Class: Carbuncle::Point

Inherits:
Object show all
Extended by:
Vectorizable::ClassMethods
Includes:
Vectorizable
Defined in:
gems/carbuncle-math/mrblib/point.rb,
gems/carbuncle-math/mrblib/000-vectorizable.rb

Overview

Note:

The point allows vectorial operations, with the values of x and y.

Represents a point in two dimensional space.

Constant Summary

Constants included from Vectorizable

Vectorizable::CLASS

Constants included from Enumerable

Enumerable::NONE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Vectorizable::ClassMethods

vectorize_properties

Methods included from Vectorizable

#%, #*, #**, #+, #-, #-@, #/, #<<, #>>, #[], #[]=, #each, #length, #to_s

Methods included from Enumerable

__update_hash, #all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #sum, #take, #take_while, #tally, #to_h, #uniq, #zip

Instance Attribute Details

#xFloat

The x value of the point.

Returns:



30
31
32
# File 'gems/carbuncle-math/mrblib/point.rb', line 30

def inspect
  "Point(#{x}, #{y})"
end

#xyCarbuncle::Point

A vectorial operation to extract [x, y] from the point or to assign it

Returns:



30
31
32
# File 'gems/carbuncle-math/mrblib/point.rb', line 30

def inspect
  "Point(#{x}, #{y})"
end

#yFloat

The y value of the point.

Returns:



30
31
32
# File 'gems/carbuncle-math/mrblib/point.rb', line 30

def inspect
  "Point(#{x}, #{y})"
end

#yxCarbuncle::Point

A vectorial operation to extract [y, x] from the point or to assign it

Examples:

vectorial operations

# swap a value with another:
point.xy = point.yx # swaps x and y
# the same as:
point.x, point.y = point.y, point.x

Returns:



30
31
32
# File 'gems/carbuncle-math/mrblib/point.rb', line 30

def inspect
  "Point(#{x}, #{y})"
end

Instance Method Details

#inspectObject



30
31
32
# File 'gems/carbuncle-math/mrblib/point.rb', line 30

def inspect
  "Point(#{x}, #{y})"
end

#sizeObject



34
35
36
# File 'gems/carbuncle-math/mrblib/point.rb', line 34

def size
  2
end

#to_aObject



38
39
40
# File 'gems/carbuncle-math/mrblib/point.rb', line 38

def to_a
  [x, y]
end