Simple dx render example.
This commit is contained in:
parent
36515556b8
commit
e0cad34d55
22 changed files with 339 additions and 60 deletions
61
src/geometry/Vector.cpp
Normal file
61
src/geometry/Vector.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include "Vector.h"
|
||||
|
||||
Vector::Vector(double x, double y, double z)
|
||||
: mX(x),
|
||||
mY(y),
|
||||
mZ(z)
|
||||
{
|
||||
updateLength();
|
||||
}
|
||||
|
||||
Vector::~Vector()
|
||||
{
|
||||
};
|
||||
|
||||
double Vector::getX() const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
double Vector::getY() const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
double Vector::getZ() const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
double Vector::getLength() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
double Vector::dotProduct(const Vector& v) const
|
||||
{
|
||||
return mX * v.mX + mY * v.mY + mZ * v.mZ;
|
||||
}
|
||||
|
||||
Vector Vector::crossProduct(const Vector& v) const
|
||||
{
|
||||
return Vector(v.mY * mZ - v.mZ * mY, v.mZ * mX - v.mX * mZ, v.mX * mY - v.mY * mX);
|
||||
}
|
||||
|
||||
Vector Vector::getNormalized() const
|
||||
{
|
||||
return Vector(mX / mLength, mY / mLength, mZ / mLength);
|
||||
}
|
||||
|
||||
void Vector::scale(double x, double y, double z)
|
||||
{
|
||||
mX = x * mX;
|
||||
mY = y * mY;
|
||||
mZ = z * mZ;
|
||||
updateLength();
|
||||
}
|
||||
|
||||
void Vector::updateLength()
|
||||
{
|
||||
mLength = std::sqrt(mX * mX + mY * mY + mZ * mZ);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue