VisimBox 1.0 VisimBox 3d simulation and visualisation ToolBox

- Main Page
- Packages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties
VisiMath.Vector2 Struct Reference

Vector2 with float components. More...

List of all members.

## Public Member Functions
| Vector2 (float val)
| Basic constructor, constructs Vector2 with specified value for all fields.
| Vector2 (float x, float y)
| Constructs Vector2 from specified coordinates.
| Vector2 (Vector2 vec)
| Copy constructor.
| Vector2 (ref Vector2 vec)
| Fast copy constructor.
| Vector2 (float[] field)
| Constructs Vector2 from float array.
| Vector2 (System.Xml.XmlReader reader)
| XML reader constructor.
void | Assing (float val)
| constructs Vector2 with specified value for all fields
void | Assign (float x, float y)
| Sets vector to specified values.
void | Assign (ref Vector2 vec)
| Sets vector as copy of source vector.
void | Assign (float[] field)
| Sets vector to values from float field.
void | MakeInvalid ()
| Makes Vector invalid by setting X component to float.NotANumber.
void | Invert ()
| Inverts vector.
void | Add (ref Vector2 vec)
| Adds specified vector to this vector - using ref for faster computing.
void | Add (Vector2 vec)
| Adds specified vector to this vector - using ref for faster computing.
void | Add (float x, float y)
| Adds values to this vector.
void | Substract (float x, float y)
| Substracts values from the vector.
void | Substract (ref Vector2 vec)
| Substracts specified vector from this vector - using ref for faster computing.
void | Substract (Vector2 vec)
| Substracts specified vector from this vector - using ref for faster computing.
void | Mul (float newscale)
| Multiplies vector by scalar value.
void | Divide (float div)
| Divides vector by the scalar value.
void | Normalize ()
| Normalizes vector. If length of the vector is zero, doesn't do anything.
void | NormalizeFast ()
| Fast normalization (less precission, usable for some operations.
void | Transform (ref Matrix2 mat)
| Transforms vector by rotational matrix.
void | Transform (ref Matrix3 mat)
| Transforms vector by homogenous matrix 3x3.
void | Clamp (ref Vector2 min, ref Vector2 max)
| Clamps values of the vector.
void | ClampMin (ref Vector2 min)
| Clamps values of the vector to minimal possible value.
void | ClampMax (ref Vector2 max)
| Clamps values of the vector to maximal possible value.
void | Interpolate (ref Vector2 target, float inter)
| Lineary interpolates vector to target vector.
bool | IsValid ()
| Checks validity of the vector.
bool | IsNormalized ()
| Returns true if vector is normalized.
float | Distance (ref Vector2 vec2)
| Returns distance to other vector.
float | DistanceFast (ref Vector2 vec2)
| Returns distance to other vector, fast but unacurrate version (good enough for distance checking)
float | DistanceSquared (ref Vector2 vec2)
| Returns squared distance to other vector, fast, for distance comparison.
float | Dot (ref Vector2 vec2)
| Dot product with another vector.
Vector2 | NormalizedCopy ()
| Returns normalized copy of this vector.
float | Angle (Vector2 v2)
| Computes angle between vectors.
float | AngleNorm (ref Vector2 v2)
| Computes angle between vectors, expects both vectors to be normalized!
override string | ToString ()
override int | GetHashCode ()
override bool | Equals (object obj)
bool | Equals (Vector2 other)
System.Xml.Schema.XmlSchema | GetSchema ()
| Reqired by IXMLserializable.
void | ReadXml (System.Xml.XmlReader reader)
| Deserializes object from XML.
void | WriteXml (System.Xml.XmlWriter writer)
| Serializes object to XML.
void | WriteXml (System.Xml.XmlWriter writer, string rootname)
| Serializes object to XML.
## Static Public Member Functions
static Vector2 | operator+ (Vector2 left, Vector2 right)
static Vector2 | operator- (Vector2 left, Vector2 right)
static Vector2 | operator- (Vector2 vec)
static Vector2 | operator* (Vector2 vec, float scale)
static Vector2 | operator* (float scale, Vector2 vec)
static Vector2 | operator/ (Vector2 vec, float scale)
static bool | operator== (Vector2 left, Vector2 right)
static bool | operator!= (Vector2 left, Vector2 right)
static bool | operator< (Vector2 left, Vector2 right)
| Compares magnitude of the vectors.
static bool | operator> (Vector2 left, Vector2 right)
| Compares magnitude of the vectors.
static bool | operator<= (Vector2 left, Vector2 right)
| Compares magnitude of the vectors.
static bool | operator>= (Vector2 left, Vector2 right)
| Compares magnitude of the vectors.
static float | Dot (ref Vector2 v1, ref Vector2 v2)
| Dot product of two vectors.
static Vector2 | Normalize (ref Vector2 v)
| Returns normalized copy of the vector.
static void | Add (ref Vector2 v1, ref Vector2 v2, out Vector2 res)
| Adds two vectors and sets res with result.
static Vector2 | Add (ref Vector2 v1, ref Vector2 v2)
| Adds two vectors and returns result.
static void | Substract (ref Vector2 v1, ref Vector2 v2, out Vector2 res)
| Substracts two vectors and sets res with result.
static Vector2 | Substract (ref Vector2 v1, ref Vector2 v2)
| Substracts two vectors and returns result.
static void | Mul (ref Vector2 v1, float newscale, out Vector2 res)
| Multiplies vector by scalar value and sets result to res.
static Vector2 | Mul (ref Vector2 v1, float newscale)
| Multiplies vector by scalar value and returns result.
static Vector2 | Divide (ref Vector2 v1, float div)
| Divides vector by scalar value and returns result.
static void | Divide (ref Vector2 v1, float div, out Vector2 res)
| Divides vector by scalar value and returns result.
static void | Clamp (ref Vector2 v1, ref Vector2 min, ref Vector2 max, out Vector2 res)
| Clamps value of the vector to minimum and maximum.
static void | ClampMin (ref Vector2 v1, ref Vector2 min, out Vector2 res)
| Clamps value of the vector to minimum.
static void | ClampMax (ref Vector2 v1, ref Vector2 max, out Vector2 res)
| Clamps value of the vector to maximum.
static Vector2 | Clamp (ref Vector2 v1, ref Vector2 min, ref Vector2 max)
| Clamps value of the vector to minimum and maximum.
static Vector2 | ClampMin (Vector2 v1, ref Vector2 min)
| Clamps value of the vector to minimum.
static Vector2 | ClampMax (Vector2 v1, ref Vector2 max)
| Clamps value of the vector to maximum.
static void | Interpolate (ref Vector2 source, ref Vector2 target, float inter, out Vector2 result)
| Lineary interpolates vector to target vector.
static Vector2 | Interpolate (ref Vector2 source, ref Vector2 target, float inter)
| Lineary interpolates vector to target vector.
## Public Attributes
float | X
| X value of the vector.
float | Y
| Y value of the vector.
## Static Public Attributes
static readonly Vector2 | UnitX = new Vector2(1, 0)
| Defines a unit-length Vector2 that points towards the X-axis.
static readonly Vector2 | UnitY = new Vector2(0, 1)
| Defines a unit-length Vector2 that points towards the Y-axis.
static readonly Vector2 | Zero = new Vector2(0, 0)
| Defines a zero-length Vector2.
static readonly Vector2 | One = new Vector2(1, 1)
| Defines an instance with all components set to 1.
static readonly Vector2 | Invalid = new Vector2(float.NaN)
| Invalid vector.
static readonly int | SizeInBytes = Marshal.SizeOf(new Vector2())
| Defines the size of the Vector2 struct in bytes.
## Properties
float[] | Array`[get, set]`
| Property for the vector as an float array.
float | this[int index]`[get, set]`
| An index accessor Maps index [0] -> X, [1] -> Y.
float | Length`[get, set]`
| Vector length.
float | LengthFast`[get]`
| Fast but imprecisse vector length.
float | LengthSquared`[get]`
| Squared lenght for fast distance comparison.

## Detailed Description

Vector2 with float components.

## Constructor & Destructor Documentation

VisiMath.Vector2.Vector2 | ( | float | val | ) |

Basic constructor, constructs Vector2 with specified value for all fields.

VisiMath.Vector2.Vector2 | ( | float | x,
|  | float | y
| ) |  |

Constructs Vector2 from specified coordinates.

Parameters:

  x | X coordinate
  y | Y coordinate
  z | Z coordinate

VisiMath.Vector2.Vector2 | ( | Vector2 | vec | ) |

Copy constructor.

Parameters:

  vec | Source value

VisiMath.Vector2.Vector2 | ( | ref Vector2 | vec | ) |

Fast copy constructor.

Parameters:

  vec | Source value

VisiMath.Vector2.Vector2 | ( | float[] | field | ) |

Constructs Vector2 from float array.

Exceptions:

  System.ArgumentException | Thrown if argument doesn't have at least 3 components

Parameters:

  field | float array with values, must have at least 3 elements

VisiMath.Vector2.Vector2 | ( | System.Xml.XmlReader | reader | ) |

XML reader constructor.

Parameters:

  reader | XML reader

## Member Function Documentation

void VisiMath.Vector2.Add | ( | ref Vector2 | vec | ) |

Adds specified vector to this vector - using ref for faster computing.

Parameters:

  vec | operand

void VisiMath.Vector2.Add | ( | Vector2 | vec | ) |

Adds specified vector to this vector - using ref for faster computing.

Parameters:

  vec | operand

Use ref overloaded version where possible, it's faster

void VisiMath.Vector2.Add | ( | float | x,
|  | float | y
| ) |  |

Adds values to this vector.

static void VisiMath.Vector2.Add | ( | ref Vector2 | v1,
|  | ref Vector2 | v2,
|  | out Vector2 | res
| ) |  | `[static]`

Adds two vectors and sets res with result.

Parameters:

  v1 | first operand
  v2 | second operand
  res | vector to save the result

static Vector2 VisiMath.Vector2.Add | ( | ref Vector2 | v1,
|  | ref Vector2 | v2
| ) |  | `[static]`

Adds two vectors and returns result.

Parameters:

  v1 | first operand
  v2 | second operand

Returns:
  v1+v2

float VisiMath.Vector2.Angle | ( | Vector2 | v2 | ) |

Computes angle between vectors.

Parameters:

  v2 | second operand

Returns:
  Angle between this and v2 in radians

float VisiMath.Vector2.AngleNorm | ( | ref Vector2 | v2 | ) |

Computes angle between vectors, expects both vectors to be normalized!

Parameters:

  v2 | second operand

Returns:
  Angle between this and v2 (both must be normalized vectors) in radians

void VisiMath.Vector2.Assign | ( | float[] | field | ) |

Sets vector to values from float field.

Exceptions:

  System.ArgumentException | Thrown if argument doesn't have at least 2 components

Parameters:

  field | Source values, must have at least 2 elements

void VisiMath.Vector2.Assign | ( | float | x,
|  | float | y
| ) |  |

Sets vector to specified values.

Parameters:

  x | X value
  y | Y value
  z | Z value

void VisiMath.Vector2.Assign | ( | ref Vector2 | vec | ) |

Sets vector as copy of source vector.

Parameters:

  vec | source vector

void VisiMath.Vector2.Assing | ( | float | val | ) |

constructs Vector2 with specified value for all fields

Parameters:

  val | value for all fields

void VisiMath.Vector2.Clamp | ( | ref Vector2 | min,
|  | ref Vector2 | max
| ) |  |

Clamps values of the vector.

Parameters:

  min | Minimal possible value
  max | Maximal possible value

static void VisiMath.Vector2.Clamp | ( | ref Vector2 | v1,
|  | ref Vector2 | min,
|  | ref Vector2 | max,
|  | out Vector2 | res
| ) |  | `[static]`

Clamps value of the vector to minimum and maximum.

Parameters:

  v1 | Vector to be clamped
  min | Minimal allowed values
  max | Maximal allowed values
  res | Ouput vector

static Vector2 VisiMath.Vector2.Clamp | ( | ref Vector2 | v1,
|  | ref Vector2 | min,
|  | ref Vector2 | max
| ) |  | `[static]`

Clamps value of the vector to minimum and maximum.

Parameters:

  v1 | Vector to be clamped
  min | Minimal allowed values
  max | Maximal allowed values

Returns:
  Clamped vector

void VisiMath.Vector2.ClampMax | ( | ref Vector2 | max | ) |

Clamps values of the vector to maximal possible value.

Parameters:

  max |

static void VisiMath.Vector2.ClampMax | ( | ref Vector2 | v1,
|  | ref Vector2 | max,
|  | out Vector2 | res
| ) |  | `[static]`

Clamps value of the vector to maximum.

Parameters:

  v1 | Vector to be clamped
  max | Maximal allowed values
  res | Ouput vector

static Vector2 VisiMath.Vector2.ClampMax | ( | Vector2 | v1,
|  | ref Vector2 | max
| ) |  | `[static]`

Clamps value of the vector to maximum.

Parameters:

  v1 | Vector to be clamped
  max | Maximal allowed values

Returns:
  Clamped vector

static Vector2 VisiMath.Vector2.ClampMin | ( | Vector2 | v1,
|  | ref Vector2 | min
| ) |  | `[static]`

Clamps value of the vector to minimum.

Parameters:

  v1 | Vector to be clamped
  min | Minimal allowed values

Returns:
  Clamped vector

void VisiMath.Vector2.ClampMin | ( | ref Vector2 | min | ) |

Clamps values of the vector to minimal possible value.

Parameters:

  min |

static void VisiMath.Vector2.ClampMin | ( | ref Vector2 | v1,
|  | ref Vector2 | min,
|  | out Vector2 | res
| ) |  | `[static]`

Clamps value of the vector to minimum.

Parameters:

  v1 | Vector to be clamped
  min | Minimal allowed values
  res | Ouput vector

float VisiMath.Vector2.Distance | ( | ref Vector2 | vec2 | ) |

Returns distance to other vector.

Parameters:

  vec2 | Vector to measure the distance

Returns:
  Distance between this and vec2

float VisiMath.Vector2.DistanceFast | ( | ref Vector2 | vec2 | ) |

Returns distance to other vector, fast but unacurrate version (good enough for distance checking)

Parameters:

  vec2 | Vector to measure the distance

Returns:
  Distance between this and vec2

float VisiMath.Vector2.DistanceSquared | ( | ref Vector2 | vec2 | ) |

Returns squared distance to other vector, fast, for distance comparison.

Parameters:

  vec2 | Vector to measure the distance

Returns:
  Distance between this and vec2

static void VisiMath.Vector2.Divide | ( | ref Vector2 | v1,
|  | float | div,
|  | out Vector2 | res
| ) |  | `[static]`

Divides vector by scalar value and returns result.

Parameters:

  v1 | Vector
  div | scalar
  res | Vector to save the result to

static Vector2 VisiMath.Vector2.Divide | ( | ref Vector2 | v1,
|  | float | div
| ) |  | `[static]`

Divides vector by scalar value and returns result.

Parameters:

  v1 | Vector
  div | scalar

Returns:
  v1/div

void VisiMath.Vector2.Divide | ( | float | div | ) |

Divides vector by the scalar value.

Parameters:

  div | scalar value

static float VisiMath.Vector2.Dot | ( | ref Vector2 | v1,
|  | ref Vector2 | v2
| ) |  | `[static]`

Dot product of two vectors.

Parameters:

  v1 | first operand
  v2 | second operand

Returns:
  Dot product of the vectors

float VisiMath.Vector2.Dot | ( | ref Vector2 | vec2 | ) |

Dot product with another vector.

Parameters:

  vec2 | Second vector

Returns:
  Dot product

override bool VisiMath.Vector2.Equals | ( | object | obj | ) |

bool VisiMath.Vector2.Equals | ( | Vector2 | other | ) |

override int VisiMath.Vector2.GetHashCode | ( |  | ) |

System.Xml.Schema.XmlSchema VisiMath.Vector2.GetSchema | ( |  | ) |

Reqired by IXMLserializable.

Returns:
  Null

void VisiMath.Vector2.Interpolate | ( | ref Vector2 | target,
|  | float | inter
| ) |  |

Lineary interpolates vector to target vector.

Parameters:

  target | Target vector
  inter | Interpolation value, assumes (0-1)

static Vector2 VisiMath.Vector2.Interpolate | ( | ref Vector2 | source,
|  | ref Vector2 | target,
|  | float | inter
| ) |  | `[static]`

Lineary interpolates vector to target vector.

Parameters:

  source | Source vector
  target | Target vector
  inter | Interpolation value, assumes (0-1)

Returns:

static void VisiMath.Vector2.Interpolate | ( | ref Vector2 | source,
|  | ref Vector2 | target,
|  | float | inter,
|  | out Vector2 | result
| ) |  | `[static]`

Lineary interpolates vector to target vector.

Parameters:

  source | Source vector
  target | Target vector
  inter | Interpolation value, assumes (0-1)
  result | Vector to save result to

void VisiMath.Vector2.Invert | ( |  | ) |

Inverts vector.

bool VisiMath.Vector2.IsNormalized | ( |  | ) |

Returns true if vector is normalized.

Returns:

bool VisiMath.Vector2.IsValid | ( |  | ) |

Checks validity of the vector.

Returns:
  True if vector.X is not notanumber

void VisiMath.Vector2.MakeInvalid | ( |  | ) |

Makes Vector invalid by setting X component to float.NotANumber.

void VisiMath.Vector2.Mul | ( | float | newscale | ) |

Multiplies vector by scalar value.

Parameters:

  newscale | Scalar value

static void VisiMath.Vector2.Mul | ( | ref Vector2 | v1,
|  | float | newscale,
|  | out Vector2 | res
| ) |  | `[static]`

Multiplies vector by scalar value and sets result to res.

Parameters:

  v1 | vector
  newscale | scalar
  res | Vector to save result to

static Vector2 VisiMath.Vector2.Mul | ( | ref Vector2 | v1,
|  | float | newscale
| ) |  | `[static]`

Multiplies vector by scalar value and returns result.

Parameters:

  v1 | vector
  newscale | scalar

Returns:
  V1*newscale

void VisiMath.Vector2.Normalize | ( |  | ) |

Normalizes vector. If length of the vector is zero, doesn't do anything.

static Vector2 VisiMath.Vector2.Normalize | ( | ref Vector2 | v | ) | `[static]`

Returns normalized copy of the vector.

Parameters:

  v | operand

Returns:
  Normalized copy of v

Vector2 VisiMath.Vector2.NormalizedCopy | ( |  | ) |

Returns normalized copy of this vector.

Returns:
  Normalized copy

void VisiMath.Vector2.NormalizeFast | ( |  | ) |

Fast normalization (less precission, usable for some operations.

static bool VisiMath.Vector2.operator!= | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

static Vector2 VisiMath.Vector2.operator* | ( | Vector2 | vec,
|  | float | scale
| ) |  | `[static]`

static Vector2 VisiMath.Vector2.operator* | ( | float | scale,
|  | Vector2 | vec
| ) |  | `[static]`

static Vector2 VisiMath.Vector2.operator+ | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

static Vector2 VisiMath.Vector2.operator- | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

static Vector2 VisiMath.Vector2.operator- | ( | Vector2 | vec | ) | `[static]`

static Vector2 VisiMath.Vector2.operator/ | ( | Vector2 | vec,
|  | float | scale
| ) |  | `[static]`

static bool VisiMath.Vector2.operator< | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

Compares magnitude of the vectors.

Parameters:

  left | left operand
  right | right operand

Returns:
  True if left operand's lenght is smaller than right

static bool VisiMath.Vector2.operator<= | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

Compares magnitude of the vectors.

Parameters:

  left | left operand
  right | right operand

Returns:
  True if left operand's lenght is equal or smaller than right

static bool VisiMath.Vector2.operator== | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

static bool VisiMath.Vector2.operator> | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

Compares magnitude of the vectors.

Parameters:

  left | left operand
  right | right operand

Returns:
  True if left operand's lenght is bigger than right

static bool VisiMath.Vector2.operator>= | ( | Vector2 | left,
|  | Vector2 | right
| ) |  | `[static]`

Compares magnitude of the vectors.

Parameters:

  left | left operand
  right | right operand

Returns:
  True if left operand's lenght is equal or bigger than right

void VisiMath.Vector2.ReadXml | ( | System.Xml.XmlReader | reader | ) |

Deserializes object from XML.

Parameters:

  reader | XML reader

void VisiMath.Vector2.Substract | ( | ref Vector2 | vec | ) |

Substracts specified vector from this vector - using ref for faster computing.

Parameters:

  vec | operand

static void VisiMath.Vector2.Substract | ( | ref Vector2 | v1,
|  | ref Vector2 | v2,
|  | out Vector2 | res
| ) |  | `[static]`

Substracts two vectors and sets res with result.

Parameters:

  v1 | first operand
  v2 | second operand
  res | vector to save the result

void VisiMath.Vector2.Substract | ( | float | x,
|  | float | y
| ) |  |

Substracts values from the vector.

void VisiMath.Vector2.Substract | ( | Vector2 | vec | ) |

Substracts specified vector from this vector - using ref for faster computing.

Parameters:

  vec | operand

Use ref overloaded version where possible, it's faster

static Vector2 VisiMath.Vector2.Substract | ( | ref Vector2 | v1,
|  | ref Vector2 | v2
| ) |  | `[static]`

Substracts two vectors and returns result.

Parameters:

  v1 | first operand
  v2 | second operand
  res | v1-v2

Returns:

override string VisiMath.Vector2.ToString | ( |  | ) |

void VisiMath.Vector2.Transform | ( | ref Matrix3 | mat | ) |

Transforms vector by homogenous matrix 3x3.

Parameters:

  mat | Matrix

void VisiMath.Vector2.Transform | ( | ref Matrix2 | mat | ) |

Transforms vector by rotational matrix.

Parameters:

  mat | Rotational matrix

void VisiMath.Vector2.WriteXml | ( | System.Xml.XmlWriter | writer,
|  | string | rootname
| ) |  |

Serializes object to XML.

Parameters:

  writer | XML writer to save values
  rootname | Node to save value to

void VisiMath.Vector2.WriteXml | ( | System.Xml.XmlWriter | writer | ) |

Serializes object to XML.

Parameters:

  writer | XML writer to save values

## Member Data Documentation

readonly Vector2 VisiMath.Vector2.Invalid = new Vector2(float.NaN)`[static]`

Invalid vector.

readonly Vector2 VisiMath.Vector2.One = new Vector2(1, 1)`[static]`

Defines an instance with all components set to 1.

readonly int VisiMath.Vector2.SizeInBytes = Marshal.SizeOf(new Vector2())`[static]`

Defines the size of the Vector2 struct in bytes.

readonly Vector2 VisiMath.Vector2.UnitX = new Vector2(1, 0)`[static]`

Defines a unit-length Vector2 that points towards the X-axis.

readonly Vector2 VisiMath.Vector2.UnitY = new Vector2(0, 1)`[static]`

Defines a unit-length Vector2 that points towards the Y-axis.

float VisiMath.Vector2.X

X value of the vector.

float VisiMath.Vector2.Y

Y value of the vector.

readonly Vector2 VisiMath.Vector2.Zero = new Vector2(0, 0)`[static]`

Defines a zero-length Vector2.

## Property Documentation

float [] VisiMath.Vector2.Array`[get, set]`

Property for the vector as an float array.

Exceptions:

  System.ArgumentException | Thrown if argument doesnt have at least two components

float VisiMath.Vector2.Length`[get, set]`

Vector length.

Exceptions:

  System.ArgumentOutOfRangeException | Thrown if new desired length is below zero
  System.ArgumentException | Thrown if vector is zero vector.

float VisiMath.Vector2.LengthFast`[get]`

Fast but imprecisse vector length.

float VisiMath.Vector2.LengthSquared`[get]`

Squared lenght for fast distance comparison.

float VisiMath.Vector2.this[int index]`[get, set]`

An index accessor Maps index [0] -> X, [1] -> Y.

Parameters:

  index | The array index referring to a component within the vector (i.e. x, y)

Exceptions:

  System.ArgumentException | Thrown if the array argument isn't between 0 and 1

The documentation for this struct was generated from the following file:

- Vector2.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events