Class MyUtils
Inheritance
System.Object
MyUtils
Assembly: VRage.dll
Syntax
public static class MyUtils : Object
Fields
C_CRLF
Declaration
public const string C_CRLF = "\r\n"
Field Value
| Type |
Description |
| System.String |
|
DefaultNumberSuffix
Default number suffix, k = thousand, m = million, g/b = billion
Declaration
public static Tuple<string, float>[] DefaultNumberSuffix
Field Value
| Type |
Description |
| System.Tuple<System.String, System.Single>[] |
|
EmptyStringBuilder
Declaration
public static readonly StringBuilder EmptyStringBuilder
Field Value
| Type |
Description |
| System.Text.StringBuilder |
|
ZeroMatrix
Declaration
public static readonly Matrix ZeroMatrix
Field Value
Properties
MainThread
Declaration
public static Thread MainThread { get; set; }
Property Value
| Type |
Description |
| System.Threading.Thread |
|
Methods
AlignCoord(Vector2, Vector2, MyGuiDrawAlignEnum)
Declaration
public static Vector2 AlignCoord(Vector2 coordScreen, Vector2 size, MyGuiDrawAlignEnum drawAlignEnum)
Parameters
Returns
AlignIntToRight(Int32, Int32, Char)
Declaration
public static string AlignIntToRight(int value, int charsCount, char ch)
Parameters
| Type |
Name |
Description |
| System.Int32 |
value |
|
| System.Int32 |
charsCount |
|
| System.Char |
ch |
|
Returns
| Type |
Description |
| System.String |
|
AssertIsValid(Double)
Declaration
public static void AssertIsValid(double f)
Parameters
| Type |
Name |
Description |
| System.Double |
f |
|
AssertIsValid(Nullable<Vector3>)
Declaration
public static void AssertIsValid(Nullable<Vector3> vec)
Parameters
| Type |
Name |
Description |
| System.Nullable<Vector3> |
vec |
|
AssertIsValid(Single)
Declaration
public static void AssertIsValid(float f)
Parameters
| Type |
Name |
Description |
| System.Single |
f |
|
AssertIsValid(Matrix)
Declaration
public static void AssertIsValid(Matrix matrix)
Parameters
| Type |
Name |
Description |
| Matrix |
matrix |
|
AssertIsValid(MatrixD)
Declaration
public static void AssertIsValid(MatrixD matrix)
Parameters
| Type |
Name |
Description |
| MatrixD |
matrix |
|
AssertIsValid(Quaternion)
Declaration
public static void AssertIsValid(Quaternion q)
Parameters
AssertIsValid(Vector2)
Declaration
public static void AssertIsValid(Vector2 vec)
Parameters
AssertIsValid(Vector3)
Declaration
public static void AssertIsValid(Vector3 vec)
Parameters
AssertIsValid(Vector3D)
Declaration
public static void AssertIsValid(Vector3D vec)
Parameters
AssertIsValidOrZero(Matrix)
Declaration
public static void AssertIsValidOrZero(Matrix matrix)
Parameters
| Type |
Name |
Description |
| Matrix |
matrix |
|
AssertLengthValid(ref Vector3)
Declaration
public static void AssertLengthValid(ref Vector3 vec)
Parameters
AssertLengthValid(ref Vector3D)
Declaration
public static void AssertLengthValid(ref Vector3D vec)
Parameters
CheckFloatValues(Object, String, ref Nullable<Double>, ref Nullable<Double>)
Declaration
public static void CheckFloatValues(object graph, string name, ref Nullable<double> min, ref Nullable<double> max)
Parameters
| Type |
Name |
Description |
| System.Object |
graph |
|
| System.String |
name |
|
| System.Nullable<System.Double> |
min |
|
| System.Nullable<System.Double> |
max |
|
CheckMainThread(String)
Declaration
public static void CheckMainThread(string message = "")
Parameters
| Type |
Name |
Description |
| System.String |
message |
|
DeserializeValue(XmlReader, out Vector3)
Declaration
public static void DeserializeValue(XmlReader reader, out Vector3 value)
Parameters
| Type |
Name |
Description |
| System.Xml.XmlReader |
reader |
|
| Vector3 |
value |
|
DeserializeValue(XmlReader, out Vector4)
Declaration
public static void DeserializeValue(XmlReader reader, out Vector4 value)
Parameters
| Type |
Name |
Description |
| System.Xml.XmlReader |
reader |
|
| Vector4 |
value |
|
Declaration
public static string FormatByteSizePrefix(ref double byteSize)
Parameters
| Type |
Name |
Description |
| System.Double |
byteSize |
|
Returns
| Type |
Description |
| System.String |
|
GenerateBoxColors()
Declaration
public static Color[] GenerateBoxColors()
Returns
GenerateQuad(out MyQuadD, ref Vector3D, Single, Single, ref MatrixD)
Generate oriented quad by matrix
Declaration
public static void GenerateQuad(out MyQuadD quad, ref Vector3D position, float width, float height, ref MatrixD matrix)
Parameters
GetAngleBetweenVectors(Vector3, Vector3)
Calculating the Angle between two Vectors (return in radians).
Declaration
public static float GetAngleBetweenVectors(Vector3 vectorA, Vector3 vectorB)
Parameters
Returns
| Type |
Description |
| System.Single |
|
GetAngleBetweenVectorsAndNormalise(Vector3, Vector3)
Declaration
public static float GetAngleBetweenVectorsAndNormalise(Vector3 vectorA, Vector3 vectorB)
Parameters
Returns
| Type |
Description |
| System.Single |
|
GetAngleBetweenVectorsForSphereCollision(Vector3, Vector3)
Declaration
public static float GetAngleBetweenVectorsForSphereCollision(Vector3 vector1, Vector3 vector2)
Parameters
Returns
| Type |
Description |
| System.Single |
|
GetBillboardQuadAdvancedRotated(out MyQuadD, Vector3D, Single, Single, Single, Vector3D)
Declaration
public static bool GetBillboardQuadAdvancedRotated(out MyQuadD quad, Vector3D position, float radiusX, float radiusY, float angle, Vector3D cameraPosition)
Parameters
| Type |
Name |
Description |
| MyQuadD |
quad |
|
| Vector3D |
position |
|
| System.Single |
radiusX |
|
| System.Single |
radiusY |
|
| System.Single |
angle |
|
| Vector3D |
cameraPosition |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetBillboardQuadAdvancedRotated(out MyQuadD, Vector3D, Single, Single, Vector3D)
Declaration
public static bool GetBillboardQuadAdvancedRotated(out MyQuadD quad, Vector3D position, float radius, float angle, Vector3D cameraPosition)
Parameters
| Type |
Name |
Description |
| MyQuadD |
quad |
|
| Vector3D |
position |
|
| System.Single |
radius |
|
| System.Single |
angle |
|
| Vector3D |
cameraPosition |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetBillboardQuadOriented(out MyQuadD, ref Vector3D, Single, Single, ref Vector3, ref Vector3)
This billboard isn't facing the camera. It's always oriented in specified direction. May be used as thrusts, or inner light of reflector.
Declaration
public static void GetBillboardQuadOriented(out MyQuadD quad, ref Vector3D position, float width, float height, ref Vector3 leftVector, ref Vector3 upVector)
Parameters
GetBoolFromString(String)
Declaration
public static Nullable<bool> GetBoolFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.Boolean> |
|
GetBoolFromString(String, Boolean)
Declaration
public static bool GetBoolFromString(string s, bool defaultValue)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
| System.Boolean |
defaultValue |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetBoundingSphereFromBoundingBox(ref BoundingBoxD)
Declaration
public static BoundingSphereD GetBoundingSphereFromBoundingBox(ref BoundingBoxD box)
Parameters
Returns
GetByteFromString(String)
Declaration
public static Nullable<byte> GetByteFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.Byte> |
|
GetCartesianCoordinatesFromSpherical(Single, Single, Single)
Declaration
public static Vector3 GetCartesianCoordinatesFromSpherical(float angleHorizontal, float angleVertical, float radius)
Parameters
| Type |
Name |
Description |
| System.Single |
angleHorizontal |
|
| System.Single |
angleVertical |
|
| System.Single |
radius |
|
Returns
GetClampInt(Int32, Int32, Int32)
Declaration
public static int GetClampInt(int value, int min, int max)
Parameters
| Type |
Name |
Description |
| System.Int32 |
value |
|
| System.Int32 |
min |
|
| System.Int32 |
max |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetClosestPointOnLine(ref Vector3, ref Vector3, ref Vector3)
Declaration
public static Vector3 GetClosestPointOnLine(ref Vector3 linePointA, ref Vector3 linePointB, ref Vector3 point)
Parameters
Returns
GetClosestPointOnLine(ref Vector3, ref Vector3, ref Vector3, out Single)
Declaration
public static Vector3 GetClosestPointOnLine(ref Vector3 linePointA, ref Vector3 linePointB, ref Vector3 point, out float dist)
Parameters
Returns
GetClosestPointOnLine(ref Vector3D, ref Vector3D, ref Vector3D)
Declaration
public static Vector3D GetClosestPointOnLine(ref Vector3D linePointA, ref Vector3D linePointB, ref Vector3D point)
Parameters
Returns
GetClosestPointOnLine(ref Vector3D, ref Vector3D, ref Vector3D, out Double)
Declaration
public static Vector3D GetClosestPointOnLine(ref Vector3D linePointA, ref Vector3D linePointB, ref Vector3D point, out double dist)
Parameters
Returns
GetCoordAligned(Vector2, Vector2, MyGuiDrawAlignEnum)
Aligns rectangle, works in screen/texture/pixel coordinates, not normalized coordinates.
Declaration
public static Vector2 GetCoordAligned(Vector2 coordScreen, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
| Type |
Description |
| Vector2 |
Pixel coordinates for texture.
|
GetCoordAlignedFromCenter(Vector2, Vector2, MyGuiDrawAlignEnum)
Modifies input coordinate (in center) using alignment and
size of the rectangle. Result is at position inside rectangle
specified by alignment.
Declaration
public static Vector2 GetCoordAlignedFromCenter(Vector2 coordCenter, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetCoordAlignedFromRectangle(ref RectangleF, MyGuiDrawAlignEnum)
Returns coordinate within given rectangle specified by draw align. Rectangle position should be
upper left corner. Conversion assumes that Y coordinates increase downwards.
Declaration
public static Vector2 GetCoordAlignedFromRectangle(ref RectangleF rect, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetCoordAlignedFromTopLeft(Vector2, Vector2, MyGuiDrawAlignEnum)
Declaration
public static Vector2 GetCoordAlignedFromTopLeft(Vector2 topLeft, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetCoordCenterFromAligned(Vector2, Vector2, MyGuiDrawAlignEnum)
Reverses effect of alignment to compute center coordinate.
Declaration
public static Vector2 GetCoordCenterFromAligned(Vector2 alignedCoord, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetCoordTopLeftFromAligned(Vector2, Vector2, MyGuiDrawAlignEnum)
Reverses effect of alignment to compute top-left corner coordinate.
Declaration
public static Vector2 GetCoordTopLeftFromAligned(Vector2 alignedCoord, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetCoordTopLeftFromAligned(Vector2I, Vector2I, MyGuiDrawAlignEnum)
Reverses effect of alignment to compute top-left corner coordinate.
Declaration
public static Vector2I GetCoordTopLeftFromAligned(Vector2I alignedCoord, Vector2I size, MyGuiDrawAlignEnum drawAlign)
Parameters
Returns
GetEdgeSphereCollision(ref Vector3, Single, ref MyTriangle_Vertices)
Returns intersection point between sphere and its edges. But only if there is intersection between sphere and one of the edges.
If sphere intersects somewhere inside the triangle, this method will not detect it.
Declaration
public static Nullable<Vector3> GetEdgeSphereCollision(ref Vector3 sphereCenter, float sphereRadius, ref MyTriangle_Vertices triangle)
Parameters
| Type |
Name |
Description |
| Vector3 |
sphereCenter |
|
| System.Single |
sphereRadius |
|
| VRage.MyTriangle_Vertices |
triangle |
|
Returns
| Type |
Description |
| System.Nullable<Vector3> |
|
GetFixedInvalidFileNameChars()
Declaration
public static char[] GetFixedInvalidFileNameChars()
Returns
| Type |
Description |
| System.Char[] |
|
GetFixedInvalidPathChars()
Declaration
public static char[] GetFixedInvalidPathChars()
Returns
| Type |
Description |
| System.Char[] |
|
GetFloatFromString(String)
Declaration
public static Nullable<float> GetFloatFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.Single> |
|
GetFloatFromString(String, Single)
Declaration
public static float GetFloatFromString(string s, float defaultValue)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
| System.Single |
defaultValue |
|
Returns
| Type |
Description |
| System.Single |
|
GetHash(Double, Int32)
Declaration
public static int GetHash(double d, int hash = -2128831035)
Parameters
| Type |
Name |
Description |
| System.Double |
d |
|
| System.Int32 |
hash |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetHash(String, Int32)
Declaration
public static int GetHash(string str, int hash = -2128831035)
Parameters
| Type |
Name |
Description |
| System.String |
str |
|
| System.Int32 |
hash |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetHash(String, Int32, Int32, Int32)
Declaration
public static int GetHash(string str, int start, int length, int hash = -2128831035)
Parameters
| Type |
Name |
Description |
| System.String |
str |
|
| System.Int32 |
start |
|
| System.Int32 |
length |
|
| System.Int32 |
hash |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetHashUpperCase(String, Int32, Int32, Int32)
Declaration
public static int GetHashUpperCase(string str, int start, int length, int hash = -2128831035)
Parameters
| Type |
Name |
Description |
| System.String |
str |
|
| System.Int32 |
start |
|
| System.Int32 |
length |
|
| System.Int32 |
hash |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetInsidePolygonForSphereCollision(ref Vector3, ref MyTriangle_Vertices)
Return true if point is inside the triangle.
Declaration
public static bool GetInsidePolygonForSphereCollision(ref Vector3 point, ref MyTriangle_Vertices triangle)
Parameters
| Type |
Name |
Description |
| Vector3 |
point |
|
| VRage.MyTriangle_Vertices |
triangle |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetInsidePolygonForSphereCollision(ref Vector3D, ref MyTriangle_Vertices)
Return true if point is inside the triangle.
Declaration
public static bool GetInsidePolygonForSphereCollision(ref Vector3D point, ref MyTriangle_Vertices triangle)
Parameters
| Type |
Name |
Description |
| Vector3D |
point |
|
| VRage.MyTriangle_Vertices |
triangle |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetInt32FromString(String)
Declaration
public static Nullable<int> GetInt32FromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.Int32> |
|
GetIntFromString(String)
Declaration
public static Nullable<int> GetIntFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.Int32> |
|
GetIntFromString(String, Int32)
Declaration
public static int GetIntFromString(string s, int defaultValue)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
| System.Int32 |
defaultValue |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetLargestDistanceToSphere(ref Vector3D, ref BoundingSphereD)
Distance between "from" and opposite side of the "sphere". Always positive.
Declaration
public static double GetLargestDistanceToSphere(ref Vector3D from, ref BoundingSphereD sphere)
Parameters
Returns
| Type |
Description |
| System.Double |
|
GetLineBoundingBoxIntersection(ref Line, ref BoundingBox)
Calculates intersection between line and bounding box and if found, distance is returned. Otherwise null is returned.
Declaration
public static Nullable<float> GetLineBoundingBoxIntersection(ref Line line, ref BoundingBox boundingBox)
Parameters
Returns
| Type |
Description |
| System.Nullable<System.Single> |
|
GetLineTriangleIntersection(ref Line, ref MyTriangle_Vertices)
Checks whether a ray intersects a triangleVertexes. This uses the algorithm
developed by Tomas Moller and Ben Trumbore, which was published in the
Journal of Graphics Tools, pitch 2, "Fast, Minimum Storage Ray-Triangle
Intersection".
This method is implemented using the pass-by-reference versions of the
XNA math functions. Using these overloads is generally not recommended,
because they make the code less readable than the normal pass-by-value
versions. This method can be called very frequently in a tight inner loop,
however, so in this particular case the performance benefits from passing
everything by reference outweigh the loss of readability.
Declaration
public static Nullable<float> GetLineTriangleIntersection(ref Line line, ref MyTriangle_Vertices triangle)
Parameters
| Type |
Name |
Description |
| Line |
line |
|
| VRage.MyTriangle_Vertices |
triangle |
|
Returns
| Type |
Description |
| System.Nullable<System.Single> |
|
Declaration
public static int GetMaxValueFromEnum<T>()
Returns
| Type |
Description |
| System.Int32 |
|
Type Parameters
GetNormalVectorFromTriangle(ref MyTriangle_Vertices)
Declaration
public static Vector3 GetNormalVectorFromTriangle(ref MyTriangle_Vertices inputTriangle)
Parameters
| Type |
Name |
Description |
| VRage.MyTriangle_Vertices |
inputTriangle |
|
Returns
GetOpenBoundaries(Vector3[], Int32[], List<Vector3>)
Declaration
public static void GetOpenBoundaries(Vector3[] vertices, int[] indices, List<Vector3> openBoundaries)
Parameters
| Type |
Name |
Description |
| Vector3[] |
vertices |
|
| System.Int32[] |
indices |
|
| System.Collections.Generic.List<Vector3> |
openBoundaries |
|
GetPointLineDistance(ref Vector3D, ref Vector3D, ref Vector3D)
Declaration
public static double GetPointLineDistance(ref Vector3D linePointA, ref Vector3D linePointB, ref Vector3D point)
Parameters
Returns
| Type |
Description |
| System.Double |
|
GetPolyLineQuad(out MyQuadD, ref MyPolyLineD, Vector3D)
Declaration
public static void GetPolyLineQuad(out MyQuadD retQuad, ref MyPolyLineD polyLine, Vector3D cameraPosition)
Parameters
GetRandomBorderPosition(ref BoundingBox)
Declaration
public static Vector3 GetRandomBorderPosition(ref BoundingBox box)
Parameters
Returns
GetRandomBorderPosition(ref BoundingBoxD)
Declaration
public static Vector3D GetRandomBorderPosition(ref BoundingBoxD box)
Parameters
Returns
GetRandomBorderPosition(ref BoundingSphere)
Declaration
public static Vector3 GetRandomBorderPosition(ref BoundingSphere sphere)
Parameters
Returns
GetRandomBorderPosition(ref BoundingSphereD)
Declaration
public static Vector3D GetRandomBorderPosition(ref BoundingSphereD sphere)
Parameters
Returns
GetRandomDiscPosition(ref Vector3D, Double, Double, ref Vector3D, ref Vector3D)
Declaration
public static Vector3D GetRandomDiscPosition(ref Vector3D center, double minRadius, double maxRadius, ref Vector3D tangent, ref Vector3D bitangent)
Parameters
| Type |
Name |
Description |
| Vector3D |
center |
|
| System.Double |
minRadius |
|
| System.Double |
maxRadius |
|
| Vector3D |
tangent |
|
| Vector3D |
bitangent |
|
Returns
GetRandomDiscPosition(ref Vector3D, Double, ref Vector3D, ref Vector3D)
Declaration
public static Vector3D GetRandomDiscPosition(ref Vector3D center, double radius, ref Vector3D tangent, ref Vector3D bitangent)
Parameters
Returns
GetRandomDouble(Double, Double)
Declaration
public static double GetRandomDouble(double minValue, double maxValue)
Parameters
| Type |
Name |
Description |
| System.Double |
minValue |
|
| System.Double |
maxValue |
|
Returns
| Type |
Description |
| System.Double |
|
GetRandomFloat()
Declaration
public static float GetRandomFloat()
Returns
| Type |
Description |
| System.Single |
|
GetRandomFloat(Single, Single)
Declaration
public static float GetRandomFloat(float minValue, float maxValue)
Parameters
| Type |
Name |
Description |
| System.Single |
minValue |
|
| System.Single |
maxValue |
|
Returns
| Type |
Description |
| System.Single |
|
GetRandomInt(Int32)
Declaration
public static int GetRandomInt(int maxValue)
Parameters
| Type |
Name |
Description |
| System.Int32 |
maxValue |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetRandomInt(Int32, Int32)
Return random int in range of minValue to maxValue, the range of return values includes minValue but not maxValue
Declaration
public static int GetRandomInt(int minValue, int maxValue)
Parameters
| Type |
Name |
Description |
| System.Int32 |
minValue |
min
|
| System.Int32 |
maxValue |
max
|
Returns
| Type |
Description |
| System.Int32 |
|
GetRandomItem<T>(T[])
Declaration
public static T GetRandomItem<T>(this T[] list)
Parameters
| Type |
Name |
Description |
| T[] |
list |
|
Returns
Type Parameters
GetRandomItemFromList<T>(List<T>)
Declaration
public static T GetRandomItemFromList<T>(this List<T> list)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.List<T> |
list |
|
Returns
Type Parameters
GetRandomLong()
Declaration
public static long GetRandomLong()
Returns
| Type |
Description |
| System.Int64 |
|
GetRandomPerpendicularVector(in Vector3)
Declaration
public static Vector3 GetRandomPerpendicularVector(in Vector3 axis)
Parameters
Returns
GetRandomPerpendicularVector(ref Vector3D)
Declaration
public static Vector3D GetRandomPerpendicularVector(ref Vector3D axis)
Parameters
Returns
GetRandomPosition(ref BoundingBox)
Declaration
public static Vector3 GetRandomPosition(ref BoundingBox box)
Parameters
Returns
GetRandomPosition(ref BoundingBoxD)
Declaration
public static Vector3D GetRandomPosition(ref BoundingBoxD box)
Parameters
Returns
GetRandomRadian()
Declaration
public static float GetRandomRadian()
Returns
| Type |
Description |
| System.Single |
|
GetRandomSign()
Declaration
public static float GetRandomSign()
Returns
| Type |
Description |
| System.Single |
|
GetRandomTimeSpan(TimeSpan, TimeSpan)
Returns a random TimeSpan between begin (inclusive) and end (exclusive).
Declaration
public static TimeSpan GetRandomTimeSpan(TimeSpan begin, TimeSpan end)
Parameters
| Type |
Name |
Description |
| System.TimeSpan |
begin |
|
| System.TimeSpan |
end |
|
Returns
| Type |
Description |
| System.TimeSpan |
|
GetRandomVector3()
Returns a uniformly-distributed random vector from inside of a box (-1,-1,-1), (1, 1, 1)
Declaration
public static Vector3 GetRandomVector3()
Returns
GetRandomVector3CircleNormalized()
Declaration
public static Vector3 GetRandomVector3CircleNormalized()
Returns
GetRandomVector3D()
Returns a uniformly-distributed random vector from inside of a box (-1,-1,-1), (1, 1, 1)
Declaration
public static Vector3D GetRandomVector3D()
Returns
GetRandomVector3HemisphereNormalized(Vector3)
Declaration
public static Vector3 GetRandomVector3HemisphereNormalized(Vector3 normal)
Parameters
| Type |
Name |
Description |
| Vector3 |
normal |
|
Returns
GetRandomVector3MaxAngle(Single)
Declaration
public static Vector3 GetRandomVector3MaxAngle(float maxAngle)
Parameters
| Type |
Name |
Description |
| System.Single |
maxAngle |
|
Returns
GetRandomVector3Normalized()
Declaration
public static Vector3 GetRandomVector3Normalized()
Returns
GetSmallestDistanceToSphere(ref Vector3D, ref BoundingSphereD)
Calculates distance from point 'from' to boundary of 'sphere'. If point is inside the sphere, distance will be negative.
Declaration
public static double GetSmallestDistanceToSphere(ref Vector3D from, ref BoundingSphereD sphere)
Parameters
Returns
| Type |
Description |
| System.Double |
|
GetSmallestDistanceToSphereAlwaysPositive(ref Vector3D, ref BoundingSphereD)
Declaration
public static double GetSmallestDistanceToSphereAlwaysPositive(ref Vector3D from, ref BoundingSphereD sphere)
Parameters
Returns
| Type |
Description |
| System.Double |
|
GetSpherePlaneIntersection(ref BoundingSphere, ref Plane, out Single)
This tells if a sphere is BEHIND, in FRONT, or INTERSECTS a plane, also it's distance
Declaration
public static MySpherePlaneIntersectionEnum GetSpherePlaneIntersection(ref BoundingSphere sphere, ref Plane plane, out float distanceFromPlaneToSphere)
Parameters
| Type |
Name |
Description |
| BoundingSphere |
sphere |
|
| Plane |
plane |
|
| System.Single |
distanceFromPlaneToSphere |
|
Returns
GetSpherePlaneIntersection(ref BoundingSphereD, ref PlaneD, out Double)
This tells if a sphere is BEHIND, in FRONT, or INTERSECTS a plane, also it's distance
Declaration
public static MySpherePlaneIntersectionEnum GetSpherePlaneIntersection(ref BoundingSphereD sphere, ref PlaneD plane, out double distanceFromPlaneToSphere)
Parameters
Returns
GetSphereTriangleIntersection(ref BoundingSphere, ref Plane, ref MyTriangle_Vertices)
Method returns intersection point between sphere and triangle (which is defined by vertexes and plane).
If no intersection found, method returns null.
See below how intersection point can be calculated, because it's not so easy - for example sphere vs. triangle will
hardly generate just intersection point... more like intersection area or something.
Declaration
public static Nullable<Vector3> GetSphereTriangleIntersection(ref BoundingSphere sphere, ref Plane trianglePlane, ref MyTriangle_Vertices triangle)
Parameters
| Type |
Name |
Description |
| BoundingSphere |
sphere |
|
| Plane |
trianglePlane |
|
| VRage.MyTriangle_Vertices |
triangle |
|
Returns
| Type |
Description |
| System.Nullable<Vector3> |
|
Declaration
public static Vector3D GetTransformNormalNormalized(Vector3D vec, ref MatrixD matrix)
Parameters
Returns
GetUIntFromString(String)
Declaration
public static Nullable<uint> GetUIntFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.UInt32> |
|
GetUIntFromString(String, UInt32)
Declaration
public static uint GetUIntFromString(string s, uint defaultValue)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
| System.UInt32 |
defaultValue |
|
Returns
| Type |
Description |
| System.UInt32 |
|
GetULongFromString(String)
Declaration
public static Nullable<ulong> GetULongFromString(string s)
Parameters
| Type |
Name |
Description |
| System.String |
s |
|
Returns
| Type |
Description |
| System.Nullable<System.UInt64> |
|
GetVector3Scaled(Vector3D, Single)
Declaration
public static Vector3D GetVector3Scaled(Vector3D originalVector, float newLength)
Parameters
| Type |
Name |
Description |
| Vector3D |
originalVector |
|
| System.Single |
newLength |
|
Returns
HasValidLength(Vector3)
Declaration
public static bool HasValidLength(Vector3 vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
HasValidLength(Vector3D)
Declaration
public static bool HasValidLength(Vector3D vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
Init<T>(ref T)
When location is null, creates new instance, stores it in location and returns it.
When location is not null, returns it.
Declaration
public static T Init<T>(ref T location)
where T : class, new()
Parameters
| Type |
Name |
Description |
| T |
location |
|
Returns
Type Parameters
InterlockedMax(ref Int32, Int32)
Declaration
public static int InterlockedMax(ref int storage, int value)
Parameters
| Type |
Name |
Description |
| System.Int32 |
storage |
|
| System.Int32 |
value |
|
Returns
| Type |
Description |
| System.Int32 |
Previous value, not max!
|
InterlockedMax(ref Int64, Int64)
Declaration
public static void InterlockedMax(ref long storage, long value)
Parameters
| Type |
Name |
Description |
| System.Int64 |
storage |
|
| System.Int64 |
value |
|
IsEqual(Single, Single)
Declaration
public static bool IsEqual(float value1, float value2)
Parameters
| Type |
Name |
Description |
| System.Single |
value1 |
|
| System.Single |
value2 |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsEqual(Matrix, Matrix)
Declaration
public static bool IsEqual(Matrix value1, Matrix value2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsEqual(Quaternion, Quaternion)
Declaration
public static bool IsEqual(Quaternion value1, Quaternion value2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsEqual(QuaternionD, QuaternionD)
Declaration
public static bool IsEqual(QuaternionD value1, QuaternionD value2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsEqual(Vector2, Vector2)
Declaration
public static bool IsEqual(Vector2 value1, Vector2 value2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsEqual(Vector3, Vector3)
Declaration
public static bool IsEqual(Vector3 value1, Vector3 value2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsLineIntersectingBoundingSphere(ref LineD, ref BoundingSphereD)
Check intersection between line and bounding sphere
We don't use BoundingSphere.Contains(Ray ...) because ray doesn't have an end, but line does, so we need
to check if line really intersects the sphere.
Declaration
public static bool IsLineIntersectingBoundingSphere(ref LineD line, ref BoundingSphereD boundingSphere)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Double)
Declaration
public static bool IsValid(double f)
Parameters
| Type |
Name |
Description |
| System.Double |
f |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Nullable<Vector3>)
Declaration
public static bool IsValid(Nullable<Vector3> vec)
Parameters
| Type |
Name |
Description |
| System.Nullable<Vector3> |
vec |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Single)
Declaration
public static bool IsValid(float f)
Parameters
| Type |
Name |
Description |
| System.Single |
f |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Matrix)
Declaration
public static bool IsValid(Matrix matrix)
Parameters
| Type |
Name |
Description |
| Matrix |
matrix |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(MatrixD)
Declaration
public static bool IsValid(MatrixD matrix)
Parameters
| Type |
Name |
Description |
| MatrixD |
matrix |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Quaternion)
Declaration
public static bool IsValid(Quaternion q)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Vector2)
Declaration
public static bool IsValid(Vector2 vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Vector3)
Declaration
public static bool IsValid(Vector3 vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValid(Vector3D)
Declaration
public static bool IsValid(Vector3D vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValidNormal(Vector3)
Declaration
public static bool IsValidNormal(Vector3 vec)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsValidOrZero(Matrix)
Declaration
public static bool IsValidOrZero(Matrix matrix)
Parameters
| Type |
Name |
Description |
| Matrix |
matrix |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsWrongTriangle(Vector3, Vector3, Vector3)
Declaration
public static bool IsWrongTriangle(Vector3 vertex0, Vector3 vertex1, Vector3 vertex2)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Double, Single)
Declaration
public static bool IsZero(double value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| System.Double |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Single, Single)
Declaration
public static bool IsZero(float value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| System.Single |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Quaternion, Single)
Declaration
public static bool IsZero(Quaternion value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Quaternion |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(ref Quaternion, Single)
Declaration
public static bool IsZero(ref Quaternion value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Quaternion |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Vector3, Single)
Declaration
public static bool IsZero(Vector3 value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Vector3 |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(ref Vector3, Single)
Declaration
public static bool IsZero(ref Vector3 value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Vector3 |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Vector3D, Single)
Declaration
public static bool IsZero(Vector3D value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Vector3D |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(ref Vector3D, Single)
Declaration
public static bool IsZero(ref Vector3D value, float epsilon = 1E-05F)
Parameters
| Type |
Name |
Description |
| Vector3D |
value |
|
| System.Single |
epsilon |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsZero(Vector4)
Declaration
public static bool IsZero(Vector4 value)
Parameters
| Type |
Name |
Description |
| Vector4 |
value |
|
Returns
| Type |
Description |
| System.Boolean |
|
LinePlaneIntersection(Vector3D, Vector3, Vector3D, Vector3)
Declaration
public static Vector3D LinePlaneIntersection(Vector3D planePoint, Vector3 planeNormal, Vector3D lineStart, Vector3 lineDir)
Parameters
Returns
Normalize(ref Matrix, out Matrix)
Protected normalize with assert
Declaration
public static void Normalize(ref Matrix m, out Matrix normalized)
Parameters
Normalize(ref MatrixD, out MatrixD)
Declaration
public static void Normalize(ref MatrixD m, out MatrixD normalized)
Parameters
Normalize(Vector3)
Protected normalize with assert
Declaration
public static Vector3 Normalize(Vector3 vec)
Parameters
Returns
Normalize(ref Vector3, out Vector3)
Protected normalize with assert
Declaration
public static void Normalize(ref Vector3 vec, out Vector3 normalized)
Parameters
Normalize(Vector3D)
Declaration
public static Vector3D Normalize(Vector3D vec)
Parameters
Returns
Normalize(ref Vector3D, out Vector3D)
Declaration
public static void Normalize(ref Vector3D vec, out Vector3D normalized)
Parameters
PrepareCollection<TCollection, TElement>(ref TCollection)
Declaration
public static TCollection PrepareCollection<TCollection, TElement>(ref TCollection collection)
where TCollection : class, ICollection<TElement>, new()
Parameters
| Type |
Name |
Description |
| TCollection |
collection |
|
Returns
| Type |
Description |
| TCollection |
|
Type Parameters
| Name |
Description |
| TCollection |
|
| TElement |
|
ReuseCollection<TElement>(ref HashSet<TElement>)
Declaration
public static MyUtils.ClearCollectionToken<HashSet<TElement>, TElement> ReuseCollection<TElement>(ref HashSet<TElement> collection)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.HashSet<TElement> |
collection |
|
Returns
Type Parameters
| Name |
Description |
| TElement |
|
ReuseCollection<TElement>(ref List<TElement>)
Declaration
public static MyUtils.ClearCollectionToken<List<TElement>, TElement> ReuseCollection<TElement>(ref List<TElement> collection)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.List<TElement> |
collection |
|
Returns
Type Parameters
| Name |
Description |
| TElement |
|
ReuseCollection<TElement>(ref MyList<TElement>)
Declaration
public static MyUtils.ClearCollectionToken<MyList<TElement>, TElement> ReuseCollection<TElement>(ref MyList<TElement> collection)
Parameters
| Type |
Name |
Description |
| VRage.Library.Collections.MyList<TElement> |
collection |
|
Returns
Type Parameters
| Name |
Description |
| TElement |
|
ReuseCollection<TCollection, TElement>(ref TCollection)
Declaration
public static MyUtils.ClearCollectionToken<TCollection, TElement> ReuseCollection<TCollection, TElement>(ref TCollection collection)
where TCollection : class, ICollection<TElement>, new()
Parameters
| Type |
Name |
Description |
| TCollection |
collection |
|
Returns
Type Parameters
| Name |
Description |
| TCollection |
|
| TElement |
|
ReuseCollection<TKey, TValue>(ref Dictionary<TKey, TValue>)
Declaration
public static MyUtils.ClearCollectionToken<Dictionary<TKey, TValue>, KeyValuePair<TKey, TValue>> ReuseCollection<TKey, TValue>(ref Dictionary<TKey, TValue> collection)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.Dictionary<TKey, TValue> |
collection |
|
Returns
| Type |
Description |
| MyUtils.ClearCollectionToken<System.Collections.Generic.Dictionary<TKey, TValue>, System.Collections.Generic.KeyValuePair<TKey, TValue>> |
|
Type Parameters
| Name |
Description |
| TKey |
|
| TValue |
|
ReuseCollectionNested<TElement>(ref List<TElement>)
Declaration
public static MyUtils.ClearRangeToken<TElement> ReuseCollectionNested<TElement>(ref List<TElement> collection)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.List<TElement> |
collection |
|
Returns
Type Parameters
| Name |
Description |
| TElement |
|
RotationMatrixToYawPitchRoll(ref Matrix, out Single, out Single, out Single)
Declaration
public static void RotationMatrixToYawPitchRoll(ref Matrix mx, out float yaw, out float pitch, out float roll)
Parameters
| Type |
Name |
Description |
| Matrix |
mx |
|
| System.Single |
yaw |
|
| System.Single |
pitch |
|
| System.Single |
roll |
|
RotationMatrixToYawPitchRoll(ref MatrixD, out Double, out Double, out Double)
Declaration
public static void RotationMatrixToYawPitchRoll(ref MatrixD mx, out double yaw, out double pitch, out double roll)
Parameters
| Type |
Name |
Description |
| MatrixD |
mx |
|
| System.Double |
yaw |
|
| System.Double |
pitch |
|
| System.Double |
roll |
|
SerializeValue(XmlWriter, Vector3)
Declaration
public static void SerializeValue(XmlWriter writer, Vector3 v)
Parameters
| Type |
Name |
Description |
| System.Xml.XmlWriter |
writer |
|
| Vector3 |
v |
|
SerializeValue(XmlWriter, Vector4)
Declaration
public static void SerializeValue(XmlWriter writer, Vector4 v)
Parameters
| Type |
Name |
Description |
| System.Xml.XmlWriter |
writer |
|
| Vector4 |
v |
|
ShuffleList<T>(IList<T>, Int32, Nullable<Int32>)
Declaration
public static void ShuffleList<T>(this IList<T> list, int offset = 0, Nullable<int> count = null)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IList<T> |
list |
|
| System.Int32 |
offset |
|
| System.Nullable<System.Int32> |
count |
|
Type Parameters
StripInvalidChars(String)
Declaration
public static string StripInvalidChars(string filename)
Parameters
| Type |
Name |
Description |
| System.String |
filename |
|
Returns
| Type |
Description |
| System.String |
|
Swap<T>(ref T, ref T)
Declaration
public static void Swap<T>(ref T lhs, ref T rhs)
Parameters
| Type |
Name |
Description |
| T |
lhs |
|
| T |
rhs |
|
Type Parameters
Declaration
public static bool TryParseWithSuffix(this string text, NumberStyles numberStyle, IFormatProvider formatProvider, out float value, Tuple<string, float>[] suffix = null)
Parameters
| Type |
Name |
Description |
| System.String |
text |
|
| System.Globalization.NumberStyles |
numberStyle |
|
| System.IFormatProvider |
formatProvider |
|
| System.Single |
value |
|
| System.Tuple<System.String, System.Single>[] |
suffix |
|
Returns
| Type |
Description |
| System.Boolean |
|
VectorPlaneRotation(Vector3D, Vector3D, out Vector3D, out Vector3D, Single)
Declaration
public static void VectorPlaneRotation(Vector3D xVector, Vector3D yVector, out Vector3D xOut, out Vector3D yOut, float angle)
Parameters