Hey guys, I need to write a struct that measures the distance from a point (x,y,z) to the origin. I am good on how to write it as a struct, I just don't know the formula for the distance. Can someone help me out? Also, the formula for a dot product of 2 vectors.

Recommended Answers

All 2 Replies

The distance from the origin, assuming you're using Euclidean distance, is sqrt(x^2 + y^2 + z^2).

The dot product? Google it.

gotcha thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.