Class: Wicket::Coordinate

Inherits:
Struct
  • Object
show all
Includes:
Cartesian
Defined in:
lib/wicket/coordinate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cartesian

#distance_to, #to_svg, #to_wkt

Instance Attribute Details

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



2
3
4
# File 'lib/wicket/coordinate.rb', line 2

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



2
3
4
# File 'lib/wicket/coordinate.rb', line 2

def y
  @y
end

Instance Method Details

#absolutize(delta_x, delta_y) ⇒ Object

method for a reference point to create absolute coords from relative measures.



7
8
9
# File 'lib/wicket/coordinate.rb', line 7

def absolutize(delta_x,delta_y)
  self.class.new(x + delta_x , y + delta_y)
end

#reflect(remote) ⇒ Object



15
16
17
18
# File 'lib/wicket/coordinate.rb', line 15

def reflect(remote)
  x,y = relativize(remote)
  absolutize(-x,-y)
end

#relativize(remote) ⇒ Object



11
12
13
# File 'lib/wicket/coordinate.rb', line 11

def relativize(remote)
  [remote.x - x, remote.y - y]
end