120 static const vector Up =
"0 1 0";
121 static const vector Aside =
"1 0 0";
122 static const vector Forward =
"0 0 1";
123 static const vector Zero =
"0 0 0";
138 proto
string ToString(
bool beautify =
true);
153 proto
float Normalize();
156 proto
vector Normalized();
169 proto native
float Length();
182 proto native
float LengthSq();
196 proto
static native
float Distance(
vector v1,
vector v2);
210 proto
static native
float DistanceSq(
vector v1,
vector v2);
237 dir_vec[0] = p2[0] - p1[0];
238 dir_vec[1] = p2[1] - p1[1];
239 dir_vec[2] = p2[2] - p1[2];
258 return Vector(
Math.RandomFloatInclusive(-1,1),
Math.RandomFloatInclusive(-1,1),
Math.RandomFloatInclusive(-1,1)).Normalized();
273 static vector RandomDir2D()
275 return Vector(
Math.RandomFloatInclusive(-1,1),0,
Math.RandomFloatInclusive(-1,1)).Normalized();
286 return ((v1[0] * v2[0]) + (v1[1] * v2[1]) + (v1[2] * v2[2]));
301 for(
int i = 0; i < 3; i++) {
303 value[i] = value[i] - 360;
305 value[i] = value[i] + 360;
324 proto
float VectorToYaw();
338 proto native
static vector YawToVector(
float yaw);
353 proto
vector VectorToAngles();
368 proto
vector AnglesToVector();
383 proto
void RotationMatrixFromAngles(out
vector mat[3]);
465 return (vec *
Math.Cos(angle *
Math.DEG2RAD)) + ((axis * vec) *
Math.Sin(angle *
Math.DEG2RAD)) + (axis *
vector.Dot(axis, vec)) * (1 -
Math.Cos(angle *
Math.DEG2RAD));
478 return (vec *
Math.Cos(angle)) + ((axis * vec) *
Math.Sin(angle)) + (axis *
vector.Dot(axis, vec)) * (1 -
Math.Cos(angle));
490 static vector RotateAroundZero(
vector pos,
vector axis,
float cosAngle,
float sinAngle)
492 return (pos * cosAngle) + ((axis * pos) * sinAngle) + (axis *
vector.Dot(axis, pos)) * (1 - cosAngle);
506 vector offsetPos = pos - point;
507 return RotateAroundZero(offsetPos, axis, cosAngle, sinAngle) + point;
515 static vector ArrayToVec(
float arr[])
517 return Vector(arr[0], arr[1], arr[2]);
536 proto owned
string GetModule();
539 proto native owned
string ToString();
549 proto native
bool IsInherited(
typename baseType);
551 proto native
int GetVariableCount();
552 proto native owned
string GetVariableName(
int vIdx);
553 proto native
typename GetVariableType(
int vIdx);
554 proto
bool GetVariableValue(
Class var,
int vIdx, out
void val);
563 static string EnumToString(
typename e,
int enumValue)
565 int cnt = e.GetVariableCount();
568 for (
int i = 0; i < cnt; i++)
570 if (e.GetVariableType(i) ==
int && e.GetVariableValue(null, i, val) && val == enumValue)
572 return e.GetVariableName(i);
585 static int StringToEnum(
typename e,
string enumName)
587 int count = e.GetVariableCount();
590 for (
int i = 0; i < count; i++)
592 if (e.GetVariableType(i) ==
int && e.GetVariableValue(null, i, value) && e.GetVariableName(i) == enumName)
604 private void EnumTools();
605 private void ~EnumTools();
614 static string EnumToString(
typename e,
int enumValue)
616 return typename.EnumToString(e, enumValue);
625 static int StringToEnum(
typename e,
string enumName)
627 return typename.StringToEnum(e, enumName);
636 static int GetEnumSize(
typename e)
638 return e.GetVariableCount();
647 static int GetEnumValue(
typename e,
int idx)
650 e.GetVariableValue(null, idx, value);
660 static int GetLastEnumValue(
typename e)
663 e.GetVariableValue(null, e.GetVariableCount() - 1, lastValue);
bool InRange(int min, int max, bool inclusive_min=true, bool inclusive_max=true)
Check whether integer falls into an inclusive range.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.