struct SF::Vector2(T)

Overview

The utility methods Scar adds to SF::Vector2 are documented here

See also CrSFML Documentation

Included Modules

Defined in:

lib/crsfml/src/system/system.cr
scar/vec.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(x, y) #

[View source]

Class Method Detail

def self.from_polar(angle, radius = 1.0) #

Creates a vector from polar coordinates


[View source]
def self.from_polar_deg(angle, radius = 1.0) #

Creates a vector from polar coordinates (angle in degrees)


[View source]

Instance Method Detail

def /(other : SF::Vector2) #

Memberwise division of two vectors


[View source]
def <=>(other : SF::Vector2f) #

Compares two Vectors based on length


[View source]
def <=>(length : Float32) #

Compares this vector's length to the given scalar


[View source]
def <=>(other : Float64) #

Compares this vector's length to the given scalar


[View source]
def <=>(other) #

Compares this vector's length to the given scalar


[View source]
def ==(other : Number) #

Equality to a scalar: returns true if length is equal to other

Epsilon is 1e-5


[View source]
def abs #

Returns a vector with the same x and y but both positive


[View source]
def angle #

Returns the angle between the vector and the x-axis


[View source]
def angle_deg #

Returns the angle between the vector and the x-axis in degrees


[View source]
def angle_to(other : SF::Vector2f) #

Returns the angle between this Vector and another (the sign indicates which Vector is ahead)


[View source]
def angle_to_deg(other : SF::Vector2f) #

Returns the angle between this Vector and another in degrees (the sign indicates which Vector is ahead)


[View source]
def cross(other : SF::Vector2(T)) #

Returns the z component of the cross product of two vectors


[View source]
def dist(other : SF::Vector2(T)) #

Returns the euclidean distance to another point


[View source]
def dot(other : SF::Vector2(T)) #

Returns the dot product between two vectors


[View source]
def length #

[View source]
def length_squared #

[View source]
def magnitude #

Same as length


[View source]
def magnitude_squared #

Same as length_squared


[View source]
def manhattan(other : SF::Vector2(T)) #

Returns the manhattan distance to another point


[View source]
def manhattan #

Returns the manhattan distance of this vector's destination from the origin


[View source]
def new_x(nx) #

Returns a copy of self with a new x value


[View source]
def new_y(ny) #

Returns a copy of self with a new y value


[View source]
def normalized #

Returns a vector with the same direction of the original vector, but with a length of one unit


[View source]
def rotate(angle : Float32) #

Returns this vector rotated by the given angle around the origin


[View source]
def rotate(angle) #

Returns this vector rotated by the given angle around the origin


[View source]
def unit #

Returns a vector with the same direction of the original vector, but with a length of one unit


[View source]