Show / Hide Table of Contents

Class MyUtils

MyFileSystemUtils

Inheritance
System.Object
MyUtils
Namespace: VRage.Utils
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
Type Description
Matrix

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
Type Name Description
Vector2 coordScreen
Vector2 size
MyGuiDrawAlignEnum drawAlignEnum
Returns
Type Description
Vector2

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
Type Name Description
Quaternion q

AssertIsValid(Vector2)

Declaration
public static void AssertIsValid(Vector2 vec)
Parameters
Type Name Description
Vector2 vec

AssertIsValid(Vector3)

Declaration
public static void AssertIsValid(Vector3 vec)
Parameters
Type Name Description
Vector3 vec

AssertIsValid(Vector3D)

Declaration
public static void AssertIsValid(Vector3D vec)
Parameters
Type Name Description
Vector3D vec

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
Type Name Description
Vector3 vec

AssertLengthValid(ref Vector3D)

Declaration
public static void AssertLengthValid(ref Vector3D vec)
Parameters
Type Name Description
Vector3D vec

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()

Declaration
public static void CheckMainThread()

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

FormatByteSizePrefix(ref Double)

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
Type Description
Color[]

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
Type Name Description
MyQuadD quad
Vector3D position
System.Single width
System.Single height
MatrixD matrix

GetAngleBetweenVectors(Vector3, Vector3)

Calculating the Angle between two Vectors (return in radians).

Declaration
public static float GetAngleBetweenVectors(Vector3 vectorA, Vector3 vectorB)
Parameters
Type Name Description
Vector3 vectorA
Vector3 vectorB
Returns
Type Description
System.Single

GetAngleBetweenVectorsAndNormalise(Vector3, Vector3)

Declaration
public static float GetAngleBetweenVectorsAndNormalise(Vector3 vectorA, Vector3 vectorB)
Parameters
Type Name Description
Vector3 vectorA
Vector3 vectorB
Returns
Type Description
System.Single

GetAngleBetweenVectorsForSphereCollision(Vector3, Vector3)

Declaration
public static float GetAngleBetweenVectorsForSphereCollision(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1
Vector3 vector2
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
Type Name Description
MyQuadD quad
Vector3D position
System.Single width
System.Single height
Vector3 leftVector
Vector3 upVector

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
Type Name Description
BoundingBoxD box
Returns
Type Description
BoundingSphereD

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
Type Description
Vector3

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
Type Name Description
Vector3 linePointA
Vector3 linePointB
Vector3 point
Returns
Type Description
Vector3

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
Type Name Description
Vector3 linePointA
Vector3 linePointB
Vector3 point
System.Single dist
Returns
Type Description
Vector3

GetClosestPointOnLine(ref Vector3D, ref Vector3D, ref Vector3D)

Declaration
public static Vector3D GetClosestPointOnLine(ref Vector3D linePointA, ref Vector3D linePointB, ref Vector3D point)
Parameters
Type Name Description
Vector3D linePointA
Vector3D linePointB
Vector3D point
Returns
Type Description
Vector3D

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
Type Name Description
Vector3D linePointA
Vector3D linePointB
Vector3D point
System.Double dist
Returns
Type Description
Vector3D

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
Type Name Description
Vector2 coordScreen
Vector2 size
MyGuiDrawAlignEnum drawAlign
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
Type Name Description
Vector2 coordCenter
Vector2 size
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2

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
Type Name Description
RectangleF rect
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2

GetCoordAlignedFromTopLeft(Vector2, Vector2, MyGuiDrawAlignEnum)

Declaration
public static Vector2 GetCoordAlignedFromTopLeft(Vector2 topLeft, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Type Name Description
Vector2 topLeft
Vector2 size
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2

GetCoordCenterFromAligned(Vector2, Vector2, MyGuiDrawAlignEnum)

Reverses effect of alignment to compute center coordinate.

Declaration
public static Vector2 GetCoordCenterFromAligned(Vector2 alignedCoord, Vector2 size, MyGuiDrawAlignEnum drawAlign)
Parameters
Type Name Description
Vector2 alignedCoord
Vector2 size
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2

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
Type Name Description
Vector2 alignedCoord
Vector2 size
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2

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
Type Name Description
Vector2I alignedCoord
Vector2I size
MyGuiDrawAlignEnum drawAlign
Returns
Type Description
Vector2I

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
Type Name Description
Vector3D from
BoundingSphereD sphere
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
Type Name Description
Line line
BoundingBox boundingBox
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>

GetMaxValueFromEnum<T>()

Declaration
public static int GetMaxValueFromEnum<T>()
Returns
Type Description
System.Int32
Type Parameters
Name Description
T

GetNormalVectorFromTriangle(ref MyTriangle_Vertices)

Declaration
public static Vector3 GetNormalVectorFromTriangle(ref MyTriangle_Vertices inputTriangle)
Parameters
Type Name Description
VRage.MyTriangle_Vertices inputTriangle
Returns
Type Description
Vector3

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
Type Name Description
Vector3D linePointA
Vector3D linePointB
Vector3D point
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
Type Name Description
MyQuadD retQuad
MyPolyLineD polyLine
Vector3D cameraPosition

GetRandomBorderPosition(ref BoundingBox)

Declaration
public static Vector3 GetRandomBorderPosition(ref BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
Vector3

GetRandomBorderPosition(ref BoundingBoxD)

Declaration
public static Vector3D GetRandomBorderPosition(ref BoundingBoxD box)
Parameters
Type Name Description
BoundingBoxD box
Returns
Type Description
Vector3D

GetRandomBorderPosition(ref BoundingSphere)

Declaration
public static Vector3 GetRandomBorderPosition(ref BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere
Returns
Type Description
Vector3

GetRandomBorderPosition(ref BoundingSphereD)

Declaration
public static Vector3D GetRandomBorderPosition(ref BoundingSphereD sphere)
Parameters
Type Name Description
BoundingSphereD sphere
Returns
Type Description
Vector3D

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
Type Description
Vector3D

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
Type Name Description
Vector3D center
System.Double radius
Vector3D tangent
Vector3D bitangent
Returns
Type Description
Vector3D

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 Description
T
Type Parameters
Name Description
T

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 Description
T
Type Parameters
Name Description
T

GetRandomLong()

Declaration
public static long GetRandomLong()
Returns
Type Description
System.Int64

GetRandomPerpendicularVector(in Vector3)

Declaration
public static Vector3 GetRandomPerpendicularVector(in Vector3 axis)
Parameters
Type Name Description
Vector3 axis
Returns
Type Description
Vector3

GetRandomPerpendicularVector(ref Vector3D)

Declaration
public static Vector3D GetRandomPerpendicularVector(ref Vector3D axis)
Parameters
Type Name Description
Vector3D axis
Returns
Type Description
Vector3D

GetRandomPosition(ref BoundingBox)

Declaration
public static Vector3 GetRandomPosition(ref BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
Vector3

GetRandomPosition(ref BoundingBoxD)

Declaration
public static Vector3D GetRandomPosition(ref BoundingBoxD box)
Parameters
Type Name Description
BoundingBoxD box
Returns
Type Description
Vector3D

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
Type Description
Vector3

GetRandomVector3CircleNormalized()

Declaration
public static Vector3 GetRandomVector3CircleNormalized()
Returns
Type Description
Vector3

GetRandomVector3D()

Returns a uniformly-distributed random vector from inside of a box (-1,-1,-1), (1, 1, 1)

Declaration
public static Vector3D GetRandomVector3D()
Returns
Type Description
Vector3D

GetRandomVector3HemisphereNormalized(Vector3)

Declaration
public static Vector3 GetRandomVector3HemisphereNormalized(Vector3 normal)
Parameters
Type Name Description
Vector3 normal
Returns
Type Description
Vector3

GetRandomVector3MaxAngle(Single)

Declaration
public static Vector3 GetRandomVector3MaxAngle(float maxAngle)
Parameters
Type Name Description
System.Single maxAngle
Returns
Type Description
Vector3

GetRandomVector3Normalized()

Declaration
public static Vector3 GetRandomVector3Normalized()
Returns
Type Description
Vector3

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
Type Name Description
Vector3D from
BoundingSphereD sphere
Returns
Type Description
System.Double

GetSmallestDistanceToSphereAlwaysPositive(ref Vector3D, ref BoundingSphereD)

Declaration
public static double GetSmallestDistanceToSphereAlwaysPositive(ref Vector3D from, ref BoundingSphereD sphere)
Parameters
Type Name Description
Vector3D from
BoundingSphereD sphere
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
Type Description
MySpherePlaneIntersectionEnum

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
Type Name Description
BoundingSphereD sphere
PlaneD plane
System.Double distanceFromPlaneToSphere
Returns
Type Description
MySpherePlaneIntersectionEnum

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>

GetTransformNormalNormalized(Vector3D, ref MatrixD)

Declaration
public static Vector3D GetTransformNormalNormalized(Vector3D vec, ref MatrixD matrix)
Parameters
Type Name Description
Vector3D vec
MatrixD matrix
Returns
Type Description
Vector3D

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
Type Description
Vector3D

HasValidLength(Vector3)

Declaration
public static bool HasValidLength(Vector3 vec)
Parameters
Type Name Description
Vector3 vec
Returns
Type Description
System.Boolean

HasValidLength(Vector3D)

Declaration
public static bool HasValidLength(Vector3D vec)
Parameters
Type Name Description
Vector3D vec
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 Description
T
Type Parameters
Name Description
T

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
Type Name Description
Matrix value1
Matrix value2
Returns
Type Description
System.Boolean

IsEqual(Quaternion, Quaternion)

Declaration
public static bool IsEqual(Quaternion value1, Quaternion value2)
Parameters
Type Name Description
Quaternion value1
Quaternion value2
Returns
Type Description
System.Boolean

IsEqual(QuaternionD, QuaternionD)

Declaration
public static bool IsEqual(QuaternionD value1, QuaternionD value2)
Parameters
Type Name Description
QuaternionD value1
QuaternionD value2
Returns
Type Description
System.Boolean

IsEqual(Vector2, Vector2)

Declaration
public static bool IsEqual(Vector2 value1, Vector2 value2)
Parameters
Type Name Description
Vector2 value1
Vector2 value2
Returns
Type Description
System.Boolean

IsEqual(Vector3, Vector3)

Declaration
public static bool IsEqual(Vector3 value1, Vector3 value2)
Parameters
Type Name Description
Vector3 value1
Vector3 value2
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
Type Name Description
LineD line
BoundingSphereD boundingSphere
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
Type Name Description
Quaternion q
Returns
Type Description
System.Boolean

IsValid(Vector2)

Declaration
public static bool IsValid(Vector2 vec)
Parameters
Type Name Description
Vector2 vec
Returns
Type Description
System.Boolean

IsValid(Vector3)

Declaration
public static bool IsValid(Vector3 vec)
Parameters
Type Name Description
Vector3 vec
Returns
Type Description
System.Boolean

IsValid(Vector3D)

Declaration
public static bool IsValid(Vector3D vec)
Parameters
Type Name Description
Vector3D vec
Returns
Type Description
System.Boolean

IsValidNormal(Vector3)

Declaration
public static bool IsValidNormal(Vector3 vec)
Parameters
Type Name Description
Vector3 vec
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
Type Name Description
Vector3 vertex0
Vector3 vertex1
Vector3 vertex2
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
Type Name Description
Vector3D planePoint
Vector3 planeNormal
Vector3D lineStart
Vector3 lineDir
Returns
Type Description
Vector3D

Normalize(ref Matrix, out Matrix)

Protected normalize with assert

Declaration
public static void Normalize(ref Matrix m, out Matrix normalized)
Parameters
Type Name Description
Matrix m
Matrix normalized

Normalize(ref MatrixD, out MatrixD)

Declaration
public static void Normalize(ref MatrixD m, out MatrixD normalized)
Parameters
Type Name Description
MatrixD m
MatrixD normalized

Normalize(Vector3)

Protected normalize with assert

Declaration
public static Vector3 Normalize(Vector3 vec)
Parameters
Type Name Description
Vector3 vec
Returns
Type Description
Vector3

Normalize(ref Vector3, out Vector3)

Protected normalize with assert

Declaration
public static void Normalize(ref Vector3 vec, out Vector3 normalized)
Parameters
Type Name Description
Vector3 vec
Vector3 normalized

Normalize(Vector3D)

Declaration
public static Vector3D Normalize(Vector3D vec)
Parameters
Type Name Description
Vector3D vec
Returns
Type Description
Vector3D

Normalize(ref Vector3D, out Vector3D)

Declaration
public static void Normalize(ref Vector3D vec, out Vector3D normalized)
Parameters
Type Name Description
Vector3D vec
Vector3D normalized

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 Description
MyUtils.ClearCollectionToken<System.Collections.Generic.HashSet<TElement>, TElement>
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 Description
MyUtils.ClearCollectionToken<System.Collections.Generic.List<TElement>, TElement>
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 Description
MyUtils.ClearCollectionToken<VRage.Library.Collections.MyList<TElement>, TElement>
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 Description
MyUtils.ClearCollectionToken<TCollection, TElement>
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 Description
MyUtils.ClearRangeToken<TElement>
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
Name Description
T

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
Name Description
T

TryParseWithSuffix(String, NumberStyles, IFormatProvider, out Single, Tuple<String, Single>[])

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
Type Name Description
Vector3D xVector
Vector3D yVector
Vector3D xOut
Vector3D yOut
System.Single angle
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾