minor changes. started writting own 3d math library and started implementation for linux/mac

This commit is contained in:
AlphaCapella
2025-08-09 14:20:26 +02:00
parent 295444d0e5
commit 2c301b76cf
19 changed files with 291 additions and 13 deletions

46
uff.cpp Normal file
View File

@@ -0,0 +1,46 @@
class Vec3 {
public:
float x, y, z;
Vec3(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
}
Vec3 add (Vec3 other) {
Vec3 result (x + other.x, y + other.y, z + other.z);
return result;
}
Vec3 subtract (Vec3 other) {
Vec3 result (x - other.x, y - other.y, z - other.z);
return result;
}
Vec3 scalar (float scalar) {
Vec3 result (x * scalar, y * scalar, z * scalar);
return result;
}
float dot (Vec3 other) {
float result (x * other.x + y * other.y + z * other.z);
return result;
}
Vec3 cross (Vec3 other) {
Vec3 result (y*other.z - z*other.y, z*other.x - x*other.z, x*other.y - y*other.x);
return result;
}
float length () {
float result = sqrt(x*x + y*y + z*z);
return result;
}
Vec3 normalize () {
float len = sqrt(x*x + y*y + z*z);
Vec3 result (x / len, y / len, z / len);
return result;
}
};