struct SF::Vector2(T)
- SF::Vector2(T)
- Struct
- Value
- Object
Overview
The utility methods Scar
adds to SF::Vector2
are documented here
See also CrSFML Documentation
Included Modules
- Comparable(Float64)
- Comparable(Float32)
- Comparable(SF::Vector2(T))
- Enumerable(T)
Defined in:
lib/crsfml/src/system/system.crscar/vec.cr
Constructors
Class Method Summary
-
.from_polar(angle, radius = 1.0)
Creates a vector from polar coordinates
-
.from_polar_deg(angle, radius = 1.0)
Creates a vector from polar coordinates (angle in degrees)
Instance Method Summary
-
#/(other : SF::Vector2)
Memberwise division of two vectors
-
#<=>(other : SF::Vector2f)
Compares two Vectors based on length
-
#<=>(length : Float32)
Compares this vector's length to the given scalar
-
#<=>(other : Float64)
Compares this vector's length to the given scalar
-
#<=>(other)
Compares this vector's length to the given scalar
-
#==(other : Number)
Equality to a scalar: returns true if length is equal to other
-
#abs
Returns a vector with the same x and y but both positive
-
#angle
Returns the angle between the vector and the x-axis
-
#angle_deg
Returns the angle between the vector and the x-axis in degrees
-
#angle_to(other : SF::Vector2f)
Returns the angle between this Vector and another (the sign indicates which Vector is ahead)
-
#angle_to_deg(other : SF::Vector2f)
Returns the angle between this Vector and another in degrees (the sign indicates which Vector is ahead)
-
#cross(other : SF::Vector2(T))
Returns the
z
component of the cross product of two vectors -
#dist(other : SF::Vector2(T))
Returns the euclidean distance to another point
-
#dot(other : SF::Vector2(T))
Returns the dot product between two vectors
- #length
- #length_squared
-
#magnitude
Same as length
-
#magnitude_squared
Same as length_squared
-
#manhattan(other : SF::Vector2(T))
Returns the manhattan distance to another point
-
#manhattan
Returns the manhattan distance of this vector's destination from the origin
-
#new_x(nx)
Returns a copy of self with a new x value
-
#new_y(ny)
Returns a copy of self with a new y value
-
#normalized
Returns a vector with the same direction of the original vector, but with a length of one unit
-
#rotate(angle : Float32)
Returns this vector rotated by the given angle around the origin
-
#rotate(angle)
Returns this vector rotated by the given angle around the origin
-
#unit
Returns a vector with the same direction of the original vector, but with a length of one unit
Constructor Detail
Class Method Detail
Creates a vector from polar coordinates (angle in degrees)
Instance Method Detail
Equality to a scalar: returns true if length is equal to other
Epsilon is 1e-5
Returns the angle between this Vector and another (the sign indicates which Vector is ahead)
Returns the angle between this Vector and another in degrees (the sign indicates which Vector is ahead)
Returns a vector with the same direction of the original vector, but with a length of one unit
Returns a vector with the same direction of the original vector, but with a length of one unit