class Geom::Vector2d

The {Geom::Vector2d} class represents vectors in a 2 dimensional space.

There are numerous tutorials on 2D vectors available on the internet.

@version LayOut 2018

Public Class Methods

new(*args) click to toggle source

The {.new} method creates a new {Geom::Vector2d}.

@example

# A vector that runs along the X axis.
vector = Geom::Vector2d.new(1, 0)

@overload initialize

@return [Geom::Vector2d]

@overload initialize(x, y)

@param [Numeric] x The length in the x direction
@param [Numeric] y The length in the y direction
@return [Geom::Vector2d]

@overload initialize(vector)

@param [Geom::Vector2d, Array(Numeric, Numeric)] vector
@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 213
def initialize(*args)
end

Public Instance Methods

%(vector) click to toggle source

The {#%} method returns the dot product between two {Geom::Vector2d}. This is an alias of the dot method.

@example

vector = Geom::Vector2d.new(0, 2)
vector2 = Geom::Vector2d.new(1, 0)
d2 = vector % vector2

@param [Geom::Vector2d] vector

@return The dot product of the vectors

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 26
def %(vector)
end
*(vector) click to toggle source

The {#*} method returns the cross product between two {Geom::Vector2d}. This is an alias of the cross method.

@example

vector = Geom::Vector2d.new(1, 0)
vector2 = Geom::Vector2d.new(0, 1)
cross = vector * vector

@param [Geom::Vector2d] vector

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 42
def *(vector)
end
+(vector) click to toggle source

The {#+} method adds a {Geom::Vector2d} to this one.

@example

vector = Geom::Vector2d.new(0, 2)
vector2 = Geom::Vector2d.new(1, 0)
new_vector = vector + vector2

@param [Geom::Vector2d] vector

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 57
def +(vector)
end
-(vector) click to toggle source

The {#-} method subtracts a {Geom::Vector2d} from this one.

@example

vector = Geom::Vector2d.new(0, 2)
vector2 = Geom::Vector2d.new(1, 0)
new_vector = vector - vector2

@param [Geom::Vector2d] vector

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 72
def -(vector)
end
==(vector) click to toggle source

The {#==} method returns whether two {Geom::Vector2d} are equal within tolerance.

@example

vector = Geom::Vector2d.new(1, 0)
vector2 = Geom::Vector2d.new(0,1)
# Returns false
status = vector == vector2

@param [Geom::Vector2d] vector

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 89
def ==(vector)
end
[](index) click to toggle source

The {#[]} method returns the value of the {Geom::Vector2d} at the specified index.

@example

vector = Geom::Vector2d.new(1, 2)
# retrieves the y value of 2
yvalue = vector[1]

@param [Integer] index

The index into an array of two coordinates.

@return [Numeric] The value for the x or y coordinate.

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 106
def [](index)
end
[]=(index, value) click to toggle source

The {#[]=} method sets the x or y value of the {Geom::Vector2d} based on the specific index of the value.

@example

point = Geom::Vector2d.new(1,2)
point[1] = 4

@param [Numeric] index

The index for a specific x or y value in the
{Geom::Vector2d} to set

@param [Numeric] value

The value to set for x or y

@return [Numeric] The new x or y value if successful

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 126
def []=(index, value)
end
angle_between(vector) click to toggle source

The {#angle_between} method computes the angle in radians between the {Geom::Vector2d} and another {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 0)
vector2 = Geom::Vector2d.new(-1, 0)
# returns PI
angle = vector.angle_between(vector2)

@param [Geom::Vector2d] vector

@return [Numeric] The angle (in radians)

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 143
def angle_between(vector)
end
clone() click to toggle source

The {#clone} method makes a copy of the {Geom::Vector2d}. This method is equivalent to vec2 = Geom::Vector2d.new(vec).

@example

vector = Geom::Vector2d.new(1, 0)
vector2 = vector.clone

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 156
def clone
end
cross(vector) click to toggle source

The {#*} method returns the cross product between two {Geom::Vector2d}. This is an alias of the cross method.

@example

vector = Geom::Vector2d.new(1, 0)
vector2 = Geom::Vector2d.new(0, 1)
cross = vector * vector

@param [Geom::Vector2d] vector

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 172
def cross(vector)
end
dot(vector) click to toggle source

The {#%} method returns the dot product between two {Geom::Vector2d}. This is an alias of the dot method.

@example

vector = Geom::Vector2d.new(0, 2)
vector2 = Geom::Vector2d.new(1, 0)
d2 = vector % vector2

@param [Geom::Vector2d] vector

@return The dot product of the vectors

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 188
def dot(vector)
end
inspect() click to toggle source

The {#inspect} method formats the {Geom::Vector2d} as a string.

@example

point = Geom::Point2d.new(1, 2)
string = point.inspect

@return [String] the string representation of the {Geom::Vector2d}

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 225
def inspect
end
length() click to toggle source

The {#length} method returns the length of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(0, 4)
# returns 4
l = vector.length

@return [Length] The length of the {Geom::Vector2d}

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 238
def length
end
length=(length) click to toggle source

The {#length=} method sets the length of the {Geom::Vector2d}. The new length must not be 0.

@example

vector = Geom::Vector2d.new(0, 4)
l = vector.length
vector.length = 2

@param [Numeric] length

The new length for the {Geom::Vector2d}

@return [Numeric] The new length

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 255
def length=(length)
end
normalize() click to toggle source

The {#normalize} method returns a {Geom::Vector2d} that is a unit vector of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(0, 4)
# returns a new Vector2d(0, 1)
vector2 = vector.normalize

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 269
def normalize
end
normalize!() click to toggle source

The {#normalize!} method converts a {Geom::Vector2d} vector into a unit vector. Another way to do this is vector.length = 1

@example

vector = Geom::Vector2d.new(0, 4)
# modifies vector to be the Vector2d(0, 1)
vector.normalize!

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 281
def normalize!
end
parallel?(vector) click to toggle source

The {#parallel?} method determines if the {Geom::Vector2d} is parallel to another {Geom::Vector2d} to within tolerance.

@example

vector = Geom::Vector2d.new(0, 1)
vector2 = Geom::Vector2d.new(1, 2)
# returns true
status = vector.parallel?(vector2)

@param [Geom::Vector2d] vector

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 298
def parallel?(vector)
end
perpendicular?(vector) click to toggle source

The {#perpendicular?} method determines if the {Geom::Vector2d} is perpendicular to another {Geom::Vector2d} to within tolerance.

@example

vector = Geom::Vector2d.new(0, 1)
vector2 = Geom::Vector2d.new(1, 2)
# returns false
status = vector.perpendicular?(vector2)

@param [Geom::Vector2d] vector

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 315
def perpendicular?(vector)
end
reverse() click to toggle source

The {#reverse} method returns a new {Geom::Vector2d} that is the reverse of the {Geom::Vector2d}, leaving the original unchanged.

@example

vector = Geom::Vector2d.new(1, 2)
# returns the Vector2d(-1, -2)
vector2 = vector.reverse

@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 329
def reverse
end
reverse!() click to toggle source

The {#reverse!} method reverses the {Geom::Vector2d} in place.

@example

vector = Geom::Vector2d.new(1, 2)
# modifies vector to be the Vector2d(-1, -2)
vector.reverse!

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 340
def reverse!
end
same_direction?(vector) click to toggle source

The {#same_direction?} method determines if the {Geom::Vector2d} is parallel to and in the same direction as another {Geom::Vector2d} within tolerance.

@example

vector = Geom::Vector2d.new(0, 1)
vector2 = Geom::Vector2d.new(1, 2)
# returns true
status = vector.sime_direction?(vector2)

@param [Geom::Vector2d] vector

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 357
def same_direction?(vector)
end
set!(*args) click to toggle source

The {#set!} method sets the values of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 2)
vector = vector.set!([4, 5])

@overload set!(vector)

@param [Geom::Vector2d, Array(Numeric, Numeric)] vector
@return [Geom::Vector2d]

@overload set!(x, y)

@param [Numeric] x
@param [Numeric] y
@return [Geom::Vector2d]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 378
def set!(*args)
end
to_a() click to toggle source

The {#to_a} method retrieves the coordinates of the {Geom::Vector2d} in an Array.

@example

a = vector.to_a

@return [Array(Numeric, Numeric)]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 390
def to_a
end
to_s() click to toggle source

The {#to_s} method returns a string representation of the {Geom::Vector2d}.

@example

point = Geom::Vector2d.new(1, 2)
str = point.to_s

@return [String] the string representation of the {Geom::Vector2d}

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 402
def to_s
end
transform(transform) click to toggle source

The {#transform} method applies a transformation to a vector, returning a new vector. The original vector is unchanged by this method.

@example

vector = Geom::Vector2d.new(4, 5)
transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
# vector2 will be (6, 8)
vector2 = vector.transform(transformation)

@param [Geom::Transformation2d] transform

A transformation object to apply to the vector.

@return [Geom::Vector2d] the newly transformed vector

@version LayOut 2019

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 420
def transform(transform)
end
transform!(transform) click to toggle source

The {#transform!} method applies a transformation to a vector. The vector itself is modified.

@example

vector = Geom::Vector2d.new(4, 5)
transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
# vector will be (6, 8)
vector.transform!(transformation)

@param [Geom::Transformation2d] transform

A Transformation object to apply to the vector.

@return [Geom::Vector2d] the transformed vector

@version LayOut 2019

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 438
def transform!(transform)
end
unit_vector?() click to toggle source

The {#unit_vector?} method returns whether the {Geom::Vector2d} is a unit vector. This is equivalent to vector.length == 1.0

@example

vector = Geom::Vector2d.new(1, 0)
# returns true
status = vector.unit_vector

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 452
def unit_vector?
end
valid?() click to toggle source

The {#valid?} method verifies if a {Geom::Vector2d} is valid. A {Geom::Vector2d} is valid if its length is not zero.

@example

vector = Geom::Vector2d.new(0, 4)
status = vector.valid

@return [Boolean]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 465
def valid?
end
x() click to toggle source

The {#x} method retrieves the x value of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 2)
x = vector.x

@return [Numeric]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 477
def x
end
x=(x) click to toggle source

The {#x=} method sets the x coordinate of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 2)
vector.x = 7

@param [Numeric] x

The desired x value of the {Geom::Vector2d}

@return [Numeric] The new x value of the {Geom::Vector2d}

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 492
def x=(x)
end
y() click to toggle source

The {#y} method retrieves the y value of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 2)
y = vector.y

@return [Numeric]

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 504
def y
end
y=(y) click to toggle source

The {#y=} method sets the y coordinate of the {Geom::Vector2d}.

@example

vector = Geom::Vector2d.new(1, 2)
vector.y = 7

@param [Numeric] y

The desired y value of the {Geom::Vector2d}

@return [Numeric] The new y value of the {Geom::Vector2d}

@version LayOut 2018

# File lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb, line 519
def y=(y)
end