Advertisement
bojandam1

Vec3 P1

Feb 21st, 2025
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Vec3 {
  6.  
  7. float x,y,z;
  8. Vec3(float x,float y,float z):x(x),y(y),z(z) {}
  9. friend ostream& operator<<(ostream&o,const Vec3& x) {
  10. o<<"("<<x.x<<", "<<x.y<<", "<<x.z<<")";
  11. return o;
  12. }
  13. };
  14. float Dot(Vec3 v1, Vec3 v2) {
  15. return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
  16. }
  17. Vec3 Cross(Vec3 v1, Vec3 v2) {
  18. return Vec3(v1.y*v2.z-v2.y*v1.z, v1.z*v2.x-v1.x*v2.z,v1.x*v2.y-v1.y*v2.x);
  19. }
  20.  
  21.  
  22.  
  23. int main() {
  24. std::cout << Dot(Vec3(1,0,0),Vec3(0,1,0)) << std::endl;
  25. return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement