29 lines
642 B
C++
29 lines
642 B
C++
#include <iostream>
|
|
|
|
// Include the vector utilities header file
|
|
#include "vector/utils_vec.hpp"
|
|
|
|
int main()
|
|
{
|
|
vec3 *v1 = (vec3 *)malloc(sizeof(vec3) * 2);
|
|
|
|
if (v1 == nullptr)
|
|
{
|
|
fprintf(stderr, "Error: Memory allocation failed for vec3 array.\n");
|
|
return 1; // Exit with error code
|
|
}
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
v1[i].setX(i + 1.0f);
|
|
v1[i].setY(i + 2.0f);
|
|
v1[i].setZ(i + 3.0f);
|
|
}
|
|
|
|
vec3 v2 = v1[0] + v1[1];
|
|
|
|
std::cout << "v2: (" << v2.getX() << ", " << v2.getY() << ", " << v2.getZ() << ")" << std::endl;
|
|
|
|
free(v1); // Free the allocated memory
|
|
return 0;
|
|
} |