Class: MG::Point

Inherits:
Object
  • Object
show all
Defined in:
doc/API_reference.rb

Overview

node.location = MG::Point.new(10, 20)

Instance Attribute Summary collapse

Constructors collapse

Helpers collapse

Constructor Details

#initializePoint #initialize(ary) ⇒ Point #initialize(x, y) ⇒ Point

Returns a new instance of Point.

Overloads:

  • #initializePoint

    Creates a new object.

  • #initialize(ary) ⇒ Point

    Creates a new object with 2-element Array.

    Parameters:

    • ary (Array)

      2-element Array.

  • #initialize(x, y) ⇒ Point

    Creates a new object.

    Parameters:

    • x (Float)

      the x coordinate of the point.

    • y (Float)

      the y coordinate of the point.



1124
# File 'doc/API_reference.rb', line 1124

def initialize(*args); end

Instance Attribute Details

#xFloat

Returns the x coordinate of the point.

Returns:

  • (Float)

    the x coordinate of the point.



1130
1131
1132
# File 'doc/API_reference.rb', line 1130

def x
  @x
end

#yFloat

Returns the y coordinate of the point.

Returns:

  • (Float)

    the y coordinate of the point.



1133
1134
1135
# File 'doc/API_reference.rb', line 1133

def y
  @y
end

Instance Method Details

#+(point) ⇒ Point

Adds the coordinates of the receiver with the coordinates of the given point object.

Parameters:

  • point (Point)

    A coordinate.

Returns:

  • (Point)

    A new Point object.



1142
# File 'doc/API_reference.rb', line 1142

def +(point); end

#-(point) ⇒ Point

Substracts the coordinates of the receiver with the coordinates of the given point object.

Parameters:

  • point (Point)

    A coordinate.

Returns:

  • (Point)

    A new Point object.



1148
# File 'doc/API_reference.rb', line 1148

def -(point); end

#angleFloat

Calculates the angle in radians between this vector and the x-axis.

Returns:

  • (Float)

    the angle.



1163
# File 'doc/API_reference.rb', line 1163

def angle; end

#distance(point) ⇒ Float

Calculates the distance between two points.

Parameters:

  • point (Point)

    A point to calculate the distance.

Returns:

  • (Float)

    the distance.



1159
# File 'doc/API_reference.rb', line 1159

def distance(point); end

#equal?(point) ⇒ Boolean

check if the coordinates of the receiver and the coordinates of the given point object is equal.

Parameters:

  • point (Point)

    A coordinate.

Returns:

  • (Boolean)

    true if the two points contain the same X and Y values.



1154
# File 'doc/API_reference.rb', line 1154

def equal?(point); end