- #1
_Nate_
- 20
- 0
I am working on a basic physics engine for a video game. In it, models are applied forces and deal with those forces by some physics calculations.
Whenever a model is applied a force, the force is in the form of a vector originating from a point in space. The vector must be decomposed into two components: the component that is pointing from the origin of the vector to the center of mass of the object is added to the translational force vector of the model, the component that is perpendicular to the first component goes into rotational force.
I need a way to decompose these vectors into two base vectors, one pointing at the center of mass of the object, and one perpendicular to that. But the catch is, because I am doing this many times a second, the calculation needs to be very fast.
This problem is very easily solved, but I would like to know if there is any way to solve it *without* using square root, sin, or cos. Is this possible?
Keep in mind that if a formula dictates I find sqrt(a^2 + a^2) then this really isn't forcing me to use the square root function: because this is simply sqrt(2) * a, and sqrt(2) is a constant. So it's possible to use sqrt, sin, and cos at computationally fast speeds so long as their use is constant regardless of the vector used.
Is this possible?
Here are several other versions of the problem that, if solved, can be used to solve the problem as a whole:
You have a point c and a line. Find the two points on the line such that their distance from c is equal to a given value r.
You have a circle centered at c with a radius r. A ray starts with a point on the circle. Find out where the ray intersects the circle again.
Anyone have any ideas?
Whenever a model is applied a force, the force is in the form of a vector originating from a point in space. The vector must be decomposed into two components: the component that is pointing from the origin of the vector to the center of mass of the object is added to the translational force vector of the model, the component that is perpendicular to the first component goes into rotational force.
I need a way to decompose these vectors into two base vectors, one pointing at the center of mass of the object, and one perpendicular to that. But the catch is, because I am doing this many times a second, the calculation needs to be very fast.
This problem is very easily solved, but I would like to know if there is any way to solve it *without* using square root, sin, or cos. Is this possible?
Keep in mind that if a formula dictates I find sqrt(a^2 + a^2) then this really isn't forcing me to use the square root function: because this is simply sqrt(2) * a, and sqrt(2) is a constant. So it's possible to use sqrt, sin, and cos at computationally fast speeds so long as their use is constant regardless of the vector used.
Is this possible?
Here are several other versions of the problem that, if solved, can be used to solve the problem as a whole:
You have a point c and a line. Find the two points on the line such that their distance from c is equal to a given value r.
You have a circle centered at c with a radius r. A ray starts with a point on the circle. Find out where the ray intersects the circle again.
Anyone have any ideas?