A two-dimensional vector with 64-bit floating-point precision.
struct
|
Vec2D
|
implements
|
IEquatable<Vec2D>
|
/ \ | X | | Y | \ /
The serialization helper object for values of Vec2D.
public
static
readonly
field
|
Serializer
|
||
type
|
ITypeSerializerEx<Vec2D>
|
A vector with undefined value.
public
static
readonly
field
|
Undefined
|
||
type
|
Vec2D
|
The zero vector.
public
static
readonly
field
|
Zero
|
||
type
|
Vec2D
|
Checks if this vector has an undefined value.
public
property
|
IsUndefined
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
vector
has
an
undefined
value,
false
if
not. |
Remarks:
A vector is undefined if at least one component is NaN (not-a-number).
Returns the length of this vector.
public
property
|
Length
{
get
}
|
||
type
|
float64
|
||
value
|
|
The vector length. |
Returns the squared length of this vector.
public
property
|
LengthSqr
{
get
}
|
||
type
|
float64
|
||
value
|
|
The squared vector length. |
X-coordinate of vector.
public
readonly
field
|
X
|
||
type
|
float64
|
Y-coordinate of vector.
public
readonly
field
|
Y
|
||
type
|
float64
|
Creates a new instance of Vec2D.
public
constructor
|
Vec2D
(float64 x,
float64 y)
|
||
params
|
x
|
X-coordinate of vector. | |
y
|
Y-coordinate of vector. |
Adds this vector and the given one.
[Pure]
|
||||
public
method
|
Add
(Vec2D v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Adds this vector and the given one.
[Pure]
|
||||
public
method
|
Add
(float64 x,
float64 y)
|
|||
type
|
Vec2D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Computes the barycentric coordinates of this vector in the given triangle.
[Pure]
|
||||
public
method
|
Barycentric
(Vec2D a,
Vec2D b,
Vec2D c)
|
|||
type
|
Vec3D
|
|||
params
|
a
|
First vertex of triangle. | ||
b
|
Second vertex of triangle. | |||
c
|
Third vertex of triangle. | |||
returns
|
The barycentric coordinates of this vector, where X, Y and Z represent the weights for the triangle vertices a, b and c (in this order). This vector lies inside of the given triangle iff X, Y and Z are non-negative. |
Computes the component-wise ceiling of this vector.
[Pure]
|
||||
public
method
|
Ceiling
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector. |
Computes
the
cross
product
between
this
vector
and
the
given
one:
this
x
other
.
[Pure]
|
||||
public
method
|
Cross
(float64 z)
|
|||
type
|
Vec2D
|
|||
params
|
z
|
Z-component of vector (X- and Y-components are zero). | ||
returns
|
The cross product vector. |
Computes
the
cross
product
between
this
vector
and
the
given
one:
this
x
other
.
[Pure]
|
||||
public
method
|
Cross
(Vec2D v)
|
|||
type
|
float64
|
|||
params
|
v
|
The other vector. | ||
returns
|
The Z-component of the cross product vector (X- and Y-components are zero). |
Computes
the
cross
product
between
this
vector
and
the
given
one:
this
x
other
.
[Pure]
|
||||
public
method
|
Cross
(float64 x,
float64 y)
|
|||
type
|
float64
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The Z-component of the cross product vector (X- and Y-components are zero). |
Divides this vector by the given scalar value.
[Pure]
|
||||
public
method
|
Div
(float64 v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The scalar value. | ||
returns
|
The resulting vector. |
Computes the dot product between this vector and the given one.
[Pure]
|
||||
public
method
|
Dot
(Vec2D v)
|
|||
type
|
float64
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Computes the dot product between this vector and the given one.
[Pure]
|
||||
public
method
|
Dot
(float64 x,
float64 y)
|
|||
type
|
float64
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Checks if this vector and the given one are equal.
[Pure]
|
||||
public
method
|
Equals
(Vec2D v)
|
|||
type
|
bool
|
|||
params
|
v
|
The vector. | ||
returns
|
true
if
both
vectors
are
equal,
false
if
they
are
not. |
Checks if this vector and the given one are equal.
[Pure]
|
||||
public
method
|
Equals
(float64 x,
float64 y)
|
|||
type
|
bool
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
true
if
both
vectors
are
equal,
false
if
they
are
not. |
Checks if this vector and the given one are similar but necessarily equal.
[Pure]
|
||||
public
method
|
EqualsAlmost
(Vec2D v)
|
|||
type
|
bool
|
|||
params
|
v
|
The vector. | ||
returns
|
true
if
both
vectors
are
similar,
false
if
they
are
not. |
Checks if this vector and the given one are similar but necessarily equal.
[Pure]
|
||||
public
method
|
EqualsAlmost
(float64 x,
float64 y)
|
|||
type
|
bool
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
true
if
both
vectors
are
similar,
false
if
they
are
not. |
Computes the component-wise floor of this vector.
[Pure]
|
||||
public
method
|
Floor
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector. |
[Pure]
|
||||
public
override
method
|
GetHashCode
()
|
|||
type
|
int32
|
Computes the component-wise maximum of this vector and the given one.
[Pure]
|
||||
public
method
|
Max
(Vec2D v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Computes the component-wise maximum of this vector and the given one.
[Pure]
|
||||
public
method
|
Max
(float64 x,
float64 y)
|
|||
type
|
Vec2D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Computes the component-wise minimum of this vector and the given one.
[Pure]
|
||||
public
method
|
Min
(Vec2D v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Computes the component-wise minimum of this vector and the given one.
[Pure]
|
||||
public
method
|
Min
(float64 x,
float64 y)
|
|||
type
|
Vec2D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Multiplies this vector with the given one.
[Pure]
|
||||
public
method
|
Mul
(Vec2D v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Multiplies this vector with the given scalar value.
[Pure]
|
||||
public
method
|
Mul
(float64 v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The scalar value. | ||
returns
|
The resulting vector. |
Multiplies this vector with the given one.
[Pure]
|
||||
public
method
|
Mul
(float64 x,
float64 y)
|
|||
type
|
Vec2D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Negates this vector.
[Pure]
|
||||
public
method
|
Neg
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector. |
Normalizes this vector to unit length.
[Pure]
|
||||
public
method
|
Norm
()
|
|||
type
|
Vec2D
|
|||
returns
|
The resulting vector. |
Subtracts the given vector from this one.
[Pure]
|
||||
public
method
|
Sub
(Vec2D v)
|
|||
type
|
Vec2D
|
|||
params
|
v
|
The vector. | ||
returns
|
The resulting vector. |
Subtracts the given vector from this one.
[Pure]
|
||||
public
method
|
Sub
(float64 x,
float64 y)
|
|||
type
|
Vec2D
|
|||
params
|
x
|
X-component of vector. | ||
y
|
Y-component of vector. | |||
returns
|
The resulting vector. |
Returns a formatted string representation of this vector.
[Pure]
|
||||
public
override
method
|
ToString
()
|
|||
type
|
string
|
|||
returns
|
[not-null]
The
formatted
string
value. |