Suppose, I have a point (x, y, z). I have an arbitrary vector (nx, ny, nz). I want to slide the point along that vector.
Thus the new point can be:
newpoint.x = x -/+ 2n.x;
newpoint.y = y -/+ 2n.y;
newpoint.z = z -/+ 2*n.z;
This moves it backward/forward 2 unit along the normal. Is it ok?
I think this way is not correct. How the correct way can be found out?
How can this be accomplished. Any suggestion will be highly appreciated.
Take a point p0 = (x0, y0, z0) and some vector v = (vx, vy, vz). We assume here that the vector v is normalized, i.e. ||v|| = 1.
Any point p of the form
p = p0 + t*v = (x0, y0, z0) + (tvx, tvy, t*vz)
where t is a scalar value, lies along the line that you are looking for. This is very similar to what you proposed yourself, except that I have changed the value 2 to be any scalar t.
As you also say, your are moving in units that correspond to the length of the vector v. The easiest way to control the amount you move is probably to normalize v, and use the value t to control the amount you are moving.
Why don’t you think that your approach is incorrect? Did you forget to normalize the vector?
Hope this helps.
Jenny, consider using some vector library. There are plenty out there. I use tvmet.
Thank you very much for clarifying the matter.