Started by Dec 15 2012 01:05 PM

,
3 replies to this topic

Posted 15 December 2012 - 01:05 PM

Hi,

I want to find projection from a point 'P' on a line 'L'

if line is given as:

struct Line

{

vec3 pos;

vec3 direction;

}

and the point is vec3(a,b,c)

I am trying to form a function like:

vec3 ProjectionToLine( Line, Point);

I want to find projection from a point 'P' on a line 'L'

if line is given as:

struct Line

{

vec3 pos;

vec3 direction;

}

and the point is vec3(a,b,c)

I am trying to form a function like:

vec3 ProjectionToLine( Line, Point);

Posted 15 December 2012 - 01:20 PM

Assuming Line.direction has length 1, the answer is Line.pos + Line.direction * dot_product(direction, Point - Line.pos).

Posted 15 December 2012 - 01:40 PM

Assuming Line.direction has length 1, the answer is Line.pos + Line.direction * dot_product(direction, Point - Line.pos).

thank you for replying

Is it Line.pos + Line.direction * dot_product(

I know what is dot product, cross product, knowledge of trigonometry etc but I find it confusing to

apply in problems ( in way of programming ie construction functions to calculate) like:

1) Given a point and a line to find out whether it is on the left or the right side of the line

2) Find angle between a line and a plane

... etc

Is there any tutorials or any weblinks where I can find these sort of problem for practise/learn.

Any guidance or suggestion is welcome

Posted 15 December 2012 - 02:04 PM

Assuming Line.direction has length 1, the answer is Line.pos + Line.direction * dot_product(direction, Point - Line.pos).

thank you for replying

Is it Line.pos + Line.direction * dot_product(Line.direction, Point - Line.pos)

Yes, that's what I mean. Sorry about the typo.

There are several ways to think about it. Imagine the plane is the x-y plane inside a 3D space and compute the z component of cross_product(Line.direction, Point - Line.pos).I know what is dot product, cross product, knowledge of trigonometry etc but I find it confusing to

apply in problems ( in way of programming ie construction functions to calculate) like:

1) Given a point and a line to find out whether it is on the left or the right side of the line

An angle is defined between two vectors, and then it's acos(dot_product(v,w)). To compute the angle between a line and a plane, project the line onto the plane and compute the angle between the original line and the projected line.2) Find angle between a line and a plane

... etc

Is there any tutorials or any weblinks where I can find these sort of problem for practise/learn.

Any guidance or suggestion is welcome

I learned Linear Algebra in college. This is something that takes effort to push into your brain, but it's extremely useful, so you should definitely put the effort in. Perhaps Khan Academy has good material on this?