Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

VectorMath - SharpDX Inspired C++ highly customizable vector math library. Custom types, double-precision, UpperCase and lowercase component names and more.

License

Notifications You must be signed in to change notification settings

Erdroy/VectorMath

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

VectorMath

SharpDX Inspired C++ vector math library (scalar only).

Status: Production Ready

VectorMath was designed to be flexible, allows to define vectors using any integer/floating-point type. Just drag and drop source and header files into your project! That's it.

Sample code

View Projection matrix calculation

m_lookAt = m_position + m_forward;
m_view = Matrix::CreateLookAt(m_position, m_lookAt, m_up);
m_projection = Matrix::CreatePerspective(Math::DegreeToRadian * m_fov, Display::GetAspectRatio(), m_nearPlane, m_farPlane);
m_viewProjection = m_view * m_projection;
// ...
auto transformed = Vector3::Transform(somePoint, m_viewProjection);

Vector2/3/4 functionality

const auto someVector = Vector3(0.0f, 2.0f, 1.0f);
auto normalized = Vector3::Normalize(someVector);
auto dot = Vector3::Dot(someVector, normalized);

if(normalized.IsNormalized()) {...}
if(normalized.IsNaN()) {...}
if(normalized.Length() > 2) {...}
// ...

Quaternion functionality

const auto someRotation = Quaternion(Vector3::Up, 50.0f);
auto axis = someRotation.Axis();

if(someRotation.IsNormalized()) {...}
if(someRotation.IsNaN()) {...}
if(someRotation.Length() > 2) {...}
// ...

Note: Quaternions are built with float as their default type and there is no way to change it.

Defining new vector type

using Vector2i = Vector2Base<int>;
using Vector3i = Vector3Base<int>;
using Vector4i = Vector4Base<int>;

Already there are some ready-to-use types defined in the VectorMath.h file.

By default UPPERCASE component naming is enabled, look: Config.h.

Roadmap

  • Disable explicit floating-point functions for integers
  • Get rid of STD
  • SIMD Support
  • Documentation
  • More functions!

Contributions

I do accept PR. Feel free to contribute.

License

MIT

About

VectorMath - SharpDX Inspired C++ highly customizable vector math library. Custom types, double-precision, UpperCase and lowercase component names and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.