Vec3f a(1.0f, 2.0f, 3.0f); Vec3f b(4.0f, 5.0f, 6.0f); Vec3f c = a + b; // c is now (5.0, 7.0, 9.0)
Vec3f a(1.0f, 2.0f, 3.0f); Vec3f b(4.0f, 5.0f, 6.0f); float dotProduct = a.dot(b); // dotProduct is now 32.0
Vec3f a(1.0f, 0.0f, 0.0f); Vec3f b(0.0f, 1.0f, 0.0f); Vec3f c = a.cross(b); // c is now (0.0, 0.0, 1.0)In this example, two Vec3f objects are created and assigned values to represent the x and y axis, respectively. The `cross` function of the Vec3f class is then called to calculate the cross product of the two vectors. The resulting vector should be the z-axis. Vec3f is not a standard library in C++, however, it might be found in external libraries such as openFrameworks or Cinder.