i made get_angle function inside vector3 class have problem it.
the y angle fine.
the pitch angle (x) returns on destination position when base vector on (and when under opposite happening).
the amount of being wrong dependant on height difference.
angle get_angle(const vector3f& v) const { return angle( math::rad_to_deg(atan2(get_distance(v), v.z - z)) - 90.0f, math::rad_to_deg(atan2(v.y - y, v.x - x)), 0.0f); }
it's maths bad here.
what trying calculate? "angle" class represent? guess either want to:
calculate angle between 2 vectors, i.e. single scalar value. formula can found here
cos(theta) == dot(*this, v) / (norm() * v.norm())
. https://math.stackexchange.com/questions/974178/how-to-calculate-the-angle-between-2-vectors-in-3d-space-given-a-preset-functionor, convert both vectors spherical coordinates (phi, theta), , calculate delta each phi , theta, i.e. calculate 2 angles. conversion formula cartesian spherical coordinates can found here: https://en.wikipedia.org/wiki/spherical_coordinate_system#cartesian_coordinates
Comments
Post a Comment