2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _BASE_VECTOR3_HPP_
|
|
|
|
#define _BASE_VECTOR3_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "SqBase.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Class used to represent a three-dimensional vector.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
|
|
|
struct Vector3
|
|
|
|
{
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The type of value used by components of type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
typedef float Value;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Helper instances for common values mostly used as return types or comparison.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-08-04 02:21:43 +02:00
|
|
|
static const Vector3 NIL; // ( 0, 0, 0)
|
|
|
|
static const Vector3 MIN; // (<0, <0, <0)
|
|
|
|
static const Vector3 MAX; // (>0, >0, >0)
|
|
|
|
static const Vector3 LEFT; // (-1, 0, 0)
|
|
|
|
static const Vector3 RIGHT; // ( 1, 0, 0)
|
|
|
|
static const Vector3 UP; // ( 0, 1, 0)
|
|
|
|
static const Vector3 DOWN; // ( 0, -1, 0)
|
|
|
|
static const Vector3 FORWARD; // ( 0, 0, 1)
|
|
|
|
static const Vector3 BACK; // ( 0, 0, -1)
|
|
|
|
static const Vector3 ONE; // ( 1, 1, 1)
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The delimiter character to be used when extracting values from strings.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static SQChar Delim;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The x, y and z components of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
Value x, y, z;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Default constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a vector with the same scalar value for all components.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Vector3(Value sv);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a vector with the specified component values.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3(Value xv, Value yv, Value zv);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
Vector3(const Vector3 & o) = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
Vector3(Vector3 && o) = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Destructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
~Vector3() = default;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
|
|
|
Vector3 & operator = (const Vector3 & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
|
|
|
Vector3 & operator = (Vector3 && o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Scalar value assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator = (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Four-dimensional vector assignment.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator = (const Vector4 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Quaternion rotation assignment.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator = (const Quaternion & q);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator += (const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator -= (const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator *= (const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator /= (const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator %= (const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator += (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator -= (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator *= (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator /= (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator %= (Value s);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator ++ ();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 & operator -- ();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator ++ (int);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator -- (int);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator + (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator - (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator * (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator / (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator % (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator + (Value s) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator - (Value s) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator * (Value s) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator / (Value s) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator % (Value s) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary plus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator + () const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary minus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 operator - () const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Equality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator == (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Inequality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator != (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator < (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator > (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator <= (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator >= (const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const Vector3 & v) const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to retrieve the name from instances of this type.
|
|
|
|
*/
|
|
|
|
static SQInteger Typename(HSQUIRRELVM vm);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set all components to the specified scalar value.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetScalar(Value ns);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-07-24 23:10:46 +02:00
|
|
|
* Copy the values from another instance of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetVector3(const Vector3 & v);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-07-24 23:10:46 +02:00
|
|
|
* Set all components to the specified values.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetVector3Ex(Value nx, Value ny, Value nz);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy the values from a four-dimensional vector.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetVector4(const Vector4 & v);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set all components to the specified values.
|
|
|
|
*/
|
|
|
|
void SetVector4Ex(Value nx, Value ny, Value nz, Value nw);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy the values from a quaternion rotation.
|
|
|
|
*/
|
|
|
|
void SetQuaternion(const Quaternion & q);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy the values from a quaternion rotation.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetQuaternionEx(Value nx, Value ny, Value nz, Value nw);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Set the values extracted from the specified string using the specified delimiter.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-07-24 23:10:46 +02:00
|
|
|
void SetStr(CSStr values, SQChar delim);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate random values for all components of this instance.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Generate();
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate random values for all components of this instance within the specified bounds.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Generate(Value min, Value max);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Generate random values for all components of this instance within the specified bounds.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax);
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Clear the component values to default.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
x = 0.0, y = 0.0, z = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Retrieve a new instance of this type with absolute component values.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector3 Abs() const;
|
2016-05-22 05:20:38 +02:00
|
|
|
|
2016-08-04 02:34:16 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return whether is NaN.
|
|
|
|
*/
|
|
|
|
bool IsNaN() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the length.
|
|
|
|
*/
|
|
|
|
Value GetLength() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Assign the length.
|
|
|
|
*/
|
|
|
|
void SetLength(Value length);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return the squared length.
|
|
|
|
*/
|
|
|
|
Value GetLengthSquared() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Assign the squared length.
|
|
|
|
*/
|
|
|
|
void SetLengthSquared(Value length);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return normalized to unit length.
|
|
|
|
*/
|
|
|
|
Vector3 Normalized() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Normalize to unit length.
|
|
|
|
*/
|
|
|
|
void Normalize();
|
|
|
|
|
2016-08-04 02:37:26 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Calculate dot product.
|
|
|
|
*/
|
|
|
|
Value DotProduct(const Vector3 & vec) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Calculate absolute dot product.
|
|
|
|
*/
|
|
|
|
Value AbsDotProduct(const Vector3 & vec) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Calculate cross product.
|
|
|
|
*/
|
|
|
|
Vector3 CrossProduct(const Vector3 & vec) const;
|
|
|
|
|
2016-08-04 02:35:27 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return the distance between this vector and another vector.
|
|
|
|
*/
|
|
|
|
Value GetDistanceTo(const Vector3 & vec) const;
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return the squared distance between this vector and another vector.
|
|
|
|
*/
|
|
|
|
Value GetSquaredDistanceTo(const Vector3 & vec) const;
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the Vector3 type from a string.
|
|
|
|
*/
|
|
|
|
static const Vector3 & Get(CSStr str);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the Vector3 type from a string.
|
|
|
|
*/
|
|
|
|
static const Vector3 & Get(CSStr str, SQChar delim);
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
2016-08-04 02:21:43 +02:00
|
|
|
#endif // _BASE_VECTOR3_HPP_
|