Added extensive Vector3 Rotation methods in Managed code & Debug draw is always available (temporarily). #273

Merged
direnbharwani merged 3 commits from SP3-2-Physics into main 2022-11-24 12:25:48 +08:00
3 changed files with 45 additions and 19 deletions
Showing only changes of commit 9e7d7afe33 - Show all commits

View File

@ -21,6 +21,9 @@ of DigiPen Institute of Technology is prohibited.
#include <algorithm>
// Project Headers
#include "Math.hxx"
#include "Quaternion.hxx"
#include "Math/Vector/SHVec3.h"
#include "Utility/Convert.hxx"
namespace SHADE
{
@ -148,21 +151,21 @@ namespace SHADE
{
return vec - (Project(vec, normal.GetNormalised()) * 2.0f);
}
Vector3 Vector3::RotateRadians(Vector3 vec, float radians)
Vector3 Vector3::RotateX(Vector3 vec, float radians)
{
const float SINE = sin(radians);
const float COSINE = cos(radians);
return Vector3
(
vec.x * COSINE - vec.y * SINE,
vec.x * SINE + vec.y * COSINE,
vec.z
);
return Convert::ToCLI(SHVec3::RotateX(Convert::ToNative(vec), radians));
}
Vector3 Vector3::RotateDegrees(Vector3 vec, float degrees)
Vector3 Vector3::RotateY(Vector3 vec, float radians)
{
return RotateRadians(vec, Math::DegreesToRadians(degrees));
return Convert::ToCLI(SHVec3::RotateY(Convert::ToNative(vec), radians));
}
Vector3 Vector3::RotateZ(Vector3 vec, float radians)
{
return Convert::ToCLI(SHVec3::RotateZ(Convert::ToNative(vec), radians));
}
Vector3 Vector3::Rotate(Vector3 vec, Vector3 axis, float radians)
{
return Convert::ToCLI(SHVec3::Rotate(Convert::ToNative(vec), Convert::ToNative(axis), radians));
}
Vector3 Vector3::Min(Vector3 lhs, Vector3 rhs)
{

View File

@ -19,6 +19,8 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "Vector2.hxx"
value struct Quaternion;
namespace SHADE
{
///<summary>
@ -266,7 +268,7 @@ namespace SHADE
/// <returns>The Vector3 that represents vec reflected across normal.</returns>
static Vector3 Reflect(Vector3 vec, Vector3 normal);
/// <summary>
/// Rotates a Vector3 on the Z-axis by a specified angle in an anti-clockwise
/// Rotates a Vector3 about the X-axis by a specified angle in an anti-clockwise
/// direction.
/// </summary>
/// <param name="vec">A Vector3 to rotate.</param>
@ -274,17 +276,37 @@ namespace SHADE
/// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 RotateRadians(Vector3 vec, float radians);
static Vector3 RotateX(Vector3 vec, float radians);
/// <summary>
/// Rotates a Vector3 on the Z-axis by a specified angle in an anti-clockwise
/// Rotates a Vector3 about the Y-axis by a specified angle in an anti-clockwise
/// direction.
/// </summary>
/// <param name="vec">A Vector3 to rotate.</param>
/// <param name="degrees">
/// Angle to rotate the vector by in an anti-clockwise direction in degrees.
/// <param name="radians">
/// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 RotateDegrees(Vector3 vec, float degrees);
static Vector3 RotateY(Vector3 vec, float radians);
/// <summary>
/// Rotates a Vector3 about the Z-axis by a specified angle in an anti-clockwise
/// direction.
/// </summary>
/// <param name="vec">A Vector3 to rotate.</param>
/// <param name="radians">
/// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 RotateZ(Vector3 vec, float radians);
/// <summary>
/// Rotates a Vector3 about an arbitrary axis by a specified angle in an anti-clockwise
/// direction.
/// </summary>
/// <param name="vec">A Vector3 to rotate.</param>
/// <param name="radians">
/// Angle to rotate the vector by in an anti-clockwise direction in radians.
/// </param>
/// <returns>The Vector3 that represents the rotated vector.</returns>
static Vector3 Rotate(Vector3 vec, Vector3 axis, float radians);
/// <summary>
/// Computes and returns a Vector3 that is made from the smallest components of
/// the two specified Vector3s.

View File

@ -25,7 +25,6 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "Engine/Entity.hxx"
#include "Math/Vector2.hxx"
#include "Math/Vector3.hxx"
#include "Math/Quaternion.hxx"
#include "Math/Ray.hxx"
#include "Physics/RaycastHit.hxx"
@ -34,6 +33,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Color.hxx"
#include "Physics/Collision/SHPhysicsRaycastResult.h"
value struct Vector3;
namespace SHADE
{
/// <summary>