- DESCRIPTION
- Contains methods for operating on Vector2 compounds.
- PROPERTIES
- zero : Vector2
- invalid : Vector2
- sqrt_0_5 : Real64
- METHODS
- create_from(Real64 _magnitude,Radians angle).Vector2
- create_from(Real64 _magnitude,Degrees angle).Vector2
- to_String(Vector2 v).String
- Returns a string representation of 'v'.
- area(Vector2 v).Real64
- max(Vector2 v1,Vector2 v2).Vector2
- Returns a vector containing the largest x and the largest y between the two vectors.
- Example:
println( max(Vector2(3,6), Vector2(4,5)) )
# prints: (4.0,6.0)
- max(Vector2 v).Real64
- min(Vector2 v1,Vector2 v2).Vector2
- Returns a vector containing the smallest x and the smallest y between the two vectors.
- Example:
println( min(Vector2(3,6), Vector2(4,5)) )
# prints: (3.0,5.0)
- min(Vector2 v).Real64
- bounding_box(Vector2 v).Box
- bounding_circle(Vector2 v).Circle
- abs(Vector2 v).Vector2
- floor(Vector2 v).Vector2
- round(Vector2 v).Vector2
- ceiling(Vector2 v).Vector2
- distance_to(Vector2 v1,Vector2 v2).Real64
- swapped(Vector2 v).Vector2
- Returns a Vector2 with the components swapped; if v=Vector2(x,y) then v.swapped == Vector2(y,x).
- transformed(Vector2 v,Transform xform).Vector2 : native
- rotated(Vector2 v,Radians rad).Vector2
- Rotates 'v' around the origin by the given number of radians.
- Example:
v2 = v1.rotated( pi/2 )
- rotated(Vector2 v,Degrees deg).Vector2
- normalized(Vector2 v).Vector2
- Normalizes 'v' to have the same angle with magnitude 1.0.
- Example:
v = v.normalized
- dot(Vector2 v1,Vector2 v2).Real64
- Returns the dot product of 'v1' and 'v2'. Returns
v1.x*v2.x + v1.y*v2.y
Example:
dot_product = v1.dot(v2)
- cross(Vector2 v1,Vector2 v2).Real64
- parallelum(Vector2 v,Vector2 axis).Vector2
- Returns the component of 'v' that lies along the axis defined by the second parameter.
- Example:
x = v.parallelum(axis)
- perpendiculum(Vector2 v,Vector2 axis).Vector2
- parallelum(Vector2 v,Line line).Vector2
- Returns the component of 'v' that lies along the axis defined by the second parameter.
- Example:
x = v.parallelum(axis)
- perpendiculum(Vector2 v,Line line).Vector2
- projection_on(Vector2 v,Line line).Vector2
- clamped(Vector2 v,Box b).Vector2
- clamped(Vector2 v,Corners c).Vector2
- clamped(Vector2 v,Real64 x1,Real64 y1,Real64 x2,Real64 y2).Vector2
- clamped(Vector2 v,Line line).Vector2
- Returns the point along the given line segment that is closest to 'v'.
- Example:
-
closest_pt_on_line = v.clamped(line)
Notes:
- Points along the line are defined by:
-
Line(t) = line.pt1 + t * (line.pt2 - line.pt1)
where t is 0 to 1. We can define t as:
-
A = v - line.pt1
B = line.pt2 - line.pt1
t = dot(A,B) / dot(B,B)
as this is the projection of A along and proportional to B.
- is_on_line(Vector2 v,Line line[,Real64 tolerance]).Logical
- Returns true if 'v' is on the given line with the given tolerance.
- normal(Vector2 v).Vector2
- Returns the normal of the given vector.
- Example:
println( v.normal )
- radians(Vector2 v).Radians
- Returns the angle of the given vector in radians.
- Example:
println( v.radians )
- degrees(Vector2 v).Degrees
- Returns the angle of the given vector in degrees.
- Example:
println( v.degrees )
- magnitude(Vector2 v).Real64
- Returns the magnitude (radial length) of the given vector.
- Example:
println( v.magnitude )
- op+(Vector2 v1,Vector2 v2).Vector2
- op-(Vector2 v1,Vector2 v2).Vector2
- op*(Vector2 v1,Vector2 v2).Vector2
- op/(Vector2 v1,Vector2 v2).Vector2
- op%(Vector2 v1,Vector2 v2).Vector2
- op-(Vector2 v).Vector2
- op+(Vector2 v1,Real64 n).Vector2
- Adds 'n' to both components of v1. Equivalent to
v1 + Vector2(n,n)
Examples:
v = v + 5
v += 5
- op-(Vector2 v1,Real64 n).Vector2
- Subtracts 'n' from both components of v1. Equivalent to
v1 - Vector2(n,n)
Examples:
v = v - 5
v -= 5
- op*(Vector2 v1,Real64 n).Vector2
- Multiplies both components of v1 by 'n'. Equivalent to
v1 * Vector2(n,n)
Examples:
v = v * 5
v *= 5
- op/(Vector2 v1,Real64 n).Vector2
- Divides both components of v1 by 'n'. Equivalent to
v1 / Vector2(n,n)
Examples:
v = v / 5
v /= 5
- op%(Vector2 v1,Real64 n).Vector2
- Returns the Vector2 modulo of each component of 'v1' divided by 'n'. Equivalent to
v1 % Vector2(n,n)
Examples:
v = v % 5
v %= 5
- op+(Real64 n,Vector2 v).Vector2
- Equivalent to Vector2(n,n) + v
- Example:
v = 5 + v
- op-(Real64 n,Vector2 v).Vector2
- Equivalent to Vector2(n,n) - v
- Example:
v = 5 - v
- op*(Real64 n,Vector2 v).Vector2
- Equivalent to Vector2(n,n) * v
- Example:
v = 5 * v
- op/(Real64 n,Vector2 v).Vector2
- Equivalent to Vector2(n,n) / v
- Example:
v = 5 / v
- op%(Real64 n,Vector2 v).Vector2
- Equivalent to Vector2(n,n) % v
- Example:
v = 5 % v
- draw(Vector2 v,Color color[,Render render_flags]) : native
- Draws the specified color at the given point 'v'.
- Example:
v.draw( Color.red )
- init_object()
- hash_code().Int32
- create_duplicate().Object
- to_String().String
- op==(Object other).Logical {multimethod}
- op<>(Object other).Logical {multimethod}
- type_name().String : native
- runtime_type().RuntimeType : native
- runtime_properties().RuntimeProperties
- runtime_methods().RuntimeMethods
|