mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 02:35:42 +00:00
0 axis and +inf angle if resulting axis is NaN
This commit is contained in:
parent
c58fe6a2a3
commit
c53ef04da8
@ -186,6 +186,12 @@ public abstract class VirtualParadiseObjectBuilder
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TargetObject.Location.Rotation.ToAxisAngle(out Vector3d axis, out double angle);
|
TargetObject.Location.Rotation.ToAxisAngle(out Vector3d axis, out double angle);
|
||||||
|
if (Vector3d.IsNan(axis))
|
||||||
|
{
|
||||||
|
axis = Vector3d.Zero;
|
||||||
|
angle = double.PositiveInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
_ = vp_double_set(handle, ObjectRotationX, axis.X);
|
_ = vp_double_set(handle, ObjectRotationX, axis.X);
|
||||||
_ = vp_double_set(handle, ObjectRotationY, axis.Y);
|
_ = vp_double_set(handle, ObjectRotationY, axis.Y);
|
||||||
_ = vp_double_set(handle, ObjectRotationZ, axis.Z);
|
_ = vp_double_set(handle, ObjectRotationZ, axis.Z);
|
||||||
|
@ -394,6 +394,46 @@ public struct Vector3d : IEquatable<Vector3d>, IFormattable
|
|||||||
return new Vector3d(vector.X, vector.Y, vector.Z);
|
return new Vector3d(vector.X, vector.Y, vector.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a value that indicates whether the components in the specified vector are not a number
|
||||||
|
/// (<see cref="double.NaN" />).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector">A double-precision vector.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <see langword="true" /> if the components in <paramref name="vector" /> evaluate to <see cref="double.NaN" />;
|
||||||
|
/// otherwise, <see langword="false" />.
|
||||||
|
/// </returns>
|
||||||
|
public static bool IsNan(in Vector3d vector)
|
||||||
|
{
|
||||||
|
return double.IsNaN(vector.X) && double.IsNaN(vector.Y) && double.IsNaN(vector.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a value that indicates whether the components in the specified vector evaluate to positive infinity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector">A double-precision vector.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <see langword="true" /> if the components in <paramref name="vector" /> evaluate to
|
||||||
|
/// <see cref="double.PositiveInfinity" />; otherwise, <see langword="false" />.
|
||||||
|
/// </returns>
|
||||||
|
public static bool IsPositiveInfinity(in Vector3d vector)
|
||||||
|
{
|
||||||
|
return double.IsPositiveInfinity(vector.X) && double.IsPositiveInfinity(vector.Y) && double.IsPositiveInfinity(vector.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a value that indicates whether the components in the specified vector evaluate to negative infinity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector">A double-precision vector.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <see langword="true" /> if the components in <paramref name="vector" /> evaluate to
|
||||||
|
/// <see cref="double.NegativeInfinity" />; otherwise, <see langword="false" />.
|
||||||
|
/// </returns>
|
||||||
|
public static bool IsNegativeInfinity(in Vector3d vector)
|
||||||
|
{
|
||||||
|
return double.IsNegativeInfinity(vector.X) && double.IsNegativeInfinity(vector.Y) && double.IsNegativeInfinity(vector.Z);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Linearly interpolates between two vectors based on the given weighting.
|
/// Linearly interpolates between two vectors based on the given weighting.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -401,7 +441,7 @@ public struct Vector3d : IEquatable<Vector3d>, IFormattable
|
|||||||
/// <param name="b">The second source vector.</param>
|
/// <param name="b">The second source vector.</param>
|
||||||
/// <param name="t">A value between 0 and 1 indicating the weight of <paramref name="b" />.</param>
|
/// <param name="t">A value between 0 and 1 indicating the weight of <paramref name="b" />.</param>
|
||||||
/// <returns>The interpolate vector.</returns>
|
/// <returns>The interpolate vector.</returns>
|
||||||
public static Vector3d Lerp(Vector3d a, Vector3d b, double t)
|
public static Vector3d Lerp(in Vector3d a, in Vector3d b, double t)
|
||||||
{
|
{
|
||||||
Vector3d firstInfluence = a * (1.0f - t);
|
Vector3d firstInfluence = a * (1.0f - t);
|
||||||
Vector3d secondInfluence = b * t;
|
Vector3d secondInfluence = b * t;
|
||||||
|
Loading…
Reference in New Issue
Block a user