### Home Classes Methods

### In Files

- lib/geometry.rb

### Parent

Object

### Methods

- ::new
- #clone
- #distance
- #project_to_line

### Files

- LessThan5BlueLabels.txt
- AtLeast2LargeSegments.txt

### Class Index

Quicksearch

- AddLabelTool
- AllRulesAppliedGoal
- Area
- AreaConstraint
- Array
- BalancedBinaryTree
- BalancedBinaryTreeNode
- CloseObserver
- Constants
- Constraint
- CurrentLabelledShape
- DistinctShapeConstraint
- Execution
- Goal
- Grammar
- Label
- LabelledShape
- LineDescriptor
- LinearLinkedList
- LinearLinkedListNode
- NoLabelsGoal
- NoMoreRulesGoal
- NoScalesConstraint
- Numeric
- Object
- OrderedPoint
- PiList
- Point
- Project
- Robot
- Rule
- RuleGroupsObserver
- RuleLabelledShape
- RuleShapeObserver
- Segment
- ShaDeLayersObserver
- Shade
- ShadeUtils
- UndoObserver

No matching classes.

# Point

Author | Manuela Ruiz (mruiz@lcc.uma.es)

Class that represents a 3D point

### Attributes

x[RW]
y[RW]
z[RW]

### Public Class Methods

new(x, y, z = 0) click to toggle source

x | x coordinate of the point
y | y coordinate of the point
z | z coordinate of the point (optional)

Initializes the point

         # File lib/geometry.rb, line 168
    168:         def initialize(x, y, z = 0)

    169:                 @x, @y, @z = x, y, z

    170:         end

### Public Instance Methods

clone() click to toggle source

returns | a Point object identical to this

         # File lib/geometry.rb, line 195
    195:         def clone()

    196:                 return Point.new(@x, @y, @z)

    197:         end

distance(another_point) click to toggle source

another_point | a Point object
returns | the distance between this point and another_point

         # File lib/geometry.rb, line 175
    175:         def distance(another_point)

    176:                 return Math.sqrt((@x - another_point.x)**2 + (@y - another_point.y)**2)

    177:         end

project_to_line(line_descriptor, a, b) click to toggle source

line_descriptor | a LineDescriptor object
a | a Point object of the line described by line_descriptor
b | a Point object of the line described by line_descriptor, distinct from a
returns | the point in the line_descriptor that is the ortogonal projection of this point on the line described by line_descriptor

         # File lib/geometry.rb, line 184
    184:         def project_to_line(line_descriptor, a, b)

    185:                 r = ((a.y - @y)*(a.y - b.y) - (a.x - @x)*(b.x - a.x)).quo(Math.sqrt((b.x - a.x)**2 + (b.y - a.y)**2)**2)

    186:

    187:                 px = a.x + r*(b.x - a.x)

    188:                 py = a.y + r*(b.y - a.y)

    189:

    190:                 return Point.new(px, py, 0)

    191:

    192:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.