Class: Geom::Point2d
| Relationships | |
| Inherits: | Object |
Overview
The Point2d class allows you to work with a point in 2D space. Point2d is a series of values representing x and y coordinates.
The values are specified as [x, y]. For example [1, 1]. To create a point call Geom::Point2d.new, where the creation method can take a variety of arguments:
Class Method Summary
-
.new ⇒ Geom::Point2d
constructor
The .new method creates a new
Point2d.
Instance Attribute Summary
-
#x ⇒ Length
rw
The #x method returns the x value of the
Point2d. -
#x=(x) ⇒ Numeric
rw
The #x= method sets the x value of the
Point2d. -
#y ⇒ Length
rw
The #y method returns the y value of the
Point2d. -
#y=(y) ⇒ Numeric
rw
The #y= method sets the y value of the
Point2d.
Instance Method Summary
- #+(vector) ⇒ Geom::Point2d
-
#-(vector) ⇒ Geom::Point2d
The #- operator is a simple way to subtract from the current x and y values of the
Point2d. -
#==(point) ⇒ Boolean
The #== method compares two points for equality.
-
#[](index) ⇒ Length
The #[] method returns the value of the
Point2dat the specified index. -
#[]=(index, value) ⇒ Numeric
The #[]= method sets the x or y value of the
Point2dbased on the specific index of the value. -
#clone ⇒ Geom::Point2d
The #clone method creates another point identical to the
Point2dbeing cloned. -
#distance(point) ⇒ Numeric
The #distance method computes the distance from the
Point2dto anotherPoint2d. -
#inspect ⇒ String
The #inspect method formats the
Point2das a string. - #offset(vector) ⇒ Geom::Point2d
- #offset!(vector) ⇒ Geom::Point2d
-
#set!(point) ⇒ Geom::Point2d
The #set! method sets the values of the
Point2d. -
#to_a ⇒ Array(Numeric, Numeric)
The #to_a method converts the
Point2dto an array of 2 numbers. -
#to_s ⇒ String
The #to_s method returns a string representation of the
Point2d. -
#transform(transform) ⇒ Geom::Point2d
The #transform method applies a transformation to a point, returning a new point.
-
#transform!(transform) ⇒ Geom::Point2d
The #transform! method applies a transformation to a point.
-
#vector_to(point) ⇒ Geom::Vector2d
The #vector_to method returns the vector between points.
Constructor Details
.new ⇒ Point2d
.new(x, y) ⇒ Point2d
.new(point) ⇒ Point2d
Point2d
.new(x, y) ⇒ Point2d
.new(point) ⇒ Point2d
The .new method creates a new Point2d.
Instance Attribute Details
#x ⇒ Length (rw)
The #x method returns the x value of the Point2d.
#x=(x) ⇒ Numeric (rw)
The #x= method sets the x value of the Point2d.
#y ⇒ Length (rw)
The #y method returns the y value of the Point2d.
#y=(y) ⇒ Numeric (rw)
The #y= method sets the y value of the Point2d.
Instance Method Details
#+(vector) ⇒ Point2d
The #+ operator is a simple way to add to the current x and y values of the Point2d, or to set the values of the Point2d by adding a Vector2d to the Point2d.
#-(vector) ⇒ Point2d
#-(point) ⇒ Geom::Vector2d
Point2d
#-(point) ⇒ Geom::Vector2d
The #- operator is a simple way to subtract from the current x and y values of the Point2d.
#==(point) ⇒ Boolean
The #== method compares two points for equality. This uses the standard SketchUp tolerance to determine if two points are the same.
#[](index) ⇒ Length
The #[] method returns the value of the Point2d at the specified index.
#[]=(index, value) ⇒ Numeric
The #[]= method sets the x or y value of the Point2d based on the specific index of the value.
#clone ⇒ Point2d
The #clone method creates another point identical to the Point2d being cloned.
#distance(point) ⇒ Numeric
The #distance method computes the distance from the Point2d to another Point2d.
#inspect ⇒ String
The #inspect method formats the Point2d as a string.
#offset(vector) ⇒ Point2d
#offset(vector, distance) ⇒ Point2d
Point2d
#offset(vector, distance) ⇒ Point2d
The #offset method offsets the Point2d by a Vector2d and returns a new Point2d. If distance is provided, it must be non-zero.
#offset!(vector) ⇒ Point2d
#offset!(vector, distance) ⇒ Point2d
Point2d
#offset!(vector, distance) ⇒ Point2d
The #offset! method offsets the Point2d by a Vector2d. The Point2d itself is modified. The length of the vector must not be zero.
#set!(point) ⇒ Point2d
#set!(x, y) ⇒ Point2d
Point2d
#set!(x, y) ⇒ Point2d
The #set! method sets the values of the Point2d.
#to_a ⇒ Array(Numeric, Numeric)
The #to_a method converts the Point2d to an array of 2 numbers.
#to_s ⇒ String
The #to_s method returns a string representation of the Point2d.
#transform(transform) ⇒ Point2d
The #transform method applies a transformation to a point, returning a new point. The original point is unchanged by this method.
#transform!(transform) ⇒ Point2d
The #transform! method applies a transformation to a point. The point itself is modified.
#vector_to(point) ⇒ Geom::Vector2d
The #vector_to method returns the vector between points.