Files
hexapod-robot/2026-current/LEGACY/Hexapod_NEW/Vector.h
T

66 lines
1.1 KiB
C++
Raw Normal View History

// Version 1
#ifndef Servo_H
#define Servo_H
class Vector
{
public:
float x, y, z;
Vector(float X, float Y, float Z)
{
x = X;
y = Y;
z = Z;
}
void Init(float X, float Y, float Z)
{
x = X;
y = Y;
z = Z;
}
Vector()
{
}
Vector Lerp(Vector start, Vector end, float percent)
{
Vector _new = (start + ((end - start) * percent));
x = _new.x;
y = _new.y;
z = _new.z;
return _new;
}
Vector operator + (const Vector other)
{
Vector _new = Vector();
_new.x = x + other.x;
_new.y = y + other.y;
_new.z = z + other.z;
return _new;
}
Vector operator - (const Vector other)
{
Vector _new = Vector();
_new.x = x - other.x;
_new.y = y - other.y;
_new.z = z - other.z;
return _new;
}
Vector operator * (const float other)
{
Vector _new = Vector(x * other, y * other, z * other);
return _new;
}
String Print()
{
return String(x) + " " + String(y) + " " + String(z);
}
};
#endif