Sign in to follow this  

find the closest vector to point

This topic is 1110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys .

 

every segment which defined by two points there are 2 unit normal vector .

 

I dont know how to explain it but I would like to find between these two vectors, the vector which is more "looking" to the point .

 

[url=http://www.siz.co.il/]jx3einw3okgo.png[/URL]

 

EC' is the vector that I woudl like to find beacuse he is more looking to Point F .

Edited by MaorNr

Share this post


Link to post
Share on other sites

Expanding on what Álvaro said, this works because of how the dot product relates to the cosine of the angle between the two vectors in question (F - A, and C - E or D - E).

 

As found on Wikipedia, the following equation holds:  P·Q = ?P? ?Q? cos ?

 

If Q is pointing sort of in the same direct as P, as is the case with C - E relative to F - A in your example, then ? will be smaller than 90°, and the cosine will be positive.  If Q is pointing more away from P, like with D - E relative to F - A, then ? will be larger than 90°, and the cosine will be negative.  If Q is neither pointing toward nor away, but is pointing exactly to the side, then the two vectors will be at right angles, and the cosine will be exactly 0.  In that case, neither unit vector will be more toward or away, and you'll have to decide how to handle that edge case.

 

Note that the length of P and Q are involved, but are irrelevant in your case, since you know that the two unit vectors are exact opposites of each other.  If you were comparing two arbitrary vectors to find out which one is most aligned with a third vector, then you'd have to first divide by the length of the involved vectors so that you could get the cosine term on its own.  Then you'd just select the vector which produced the largest cosine value, as that would be closest to the cosine of 0, because the angle between the two vectors is 0 when the two vectors are perfectly aligned.

Edited by Andy Gainey

Share this post


Link to post
Share on other sites

The dot products of the vector F-A with the two normal vectors have different signs. Pick the positive one.

 

 

Expanding on what Álvaro said, this works because of how the dot product relates to the cosine of the angle between the two vectors in question (F - A, and C - E or D - E).

 

As found on Wikipedia, the following equation holds:  P·Q = ?P? ?Q? cos ?

 

If Q is pointing sort of in the same direct as P, as is the case with C - E relative to F - A in your example, then ? will be smaller than 90°, and the cosine will be positive.  If Q is pointing more away from P, like with D - E relative to F - A, then ? will be larger than 90°, and the cosine will be negative.  If Q is neither pointing toward nor away, but is pointing exactly to the side, then the two vectors will be at right angles, and the cosine will be exactly 0.  In that case, neither unit vector will be more toward or away, and you'll have to decide how to handle that edge case.

 

Note that the length of P and Q are involved, but are irrelevant in your case, since you know that the two unit vectors are exact opposites of each other.  If you were comparing two arbitrary vectors to find out which one is most aligned with a third vector, then you'd have to first divide by the length of the involved vectors so that you could get the cosine term on its own.  Then you'd just select the vector which produced the largest cosine value, as that would be closest to the cosine of 0, because the angle between the two vectors is 0 when the two vectors are perfectly aligned.

 

thanks you very much guys this method which you explained to me had saved to me many resources !

thanks thanks thanks !

And Alvaro I actually checked it , and it seems like I needed the negative one , thanks alvaro smile.png

Edited by MaorNr

Share this post


Link to post
Share on other sites

EC' is the vector that I woudl like to find

 

 


it seems like I needed the negative one

 

You may want to check your vector math. The EC' vector as shown in the diagram (arrow pointing from E to C') would be formed as (C' - E). Are you perhaps using (E - C') instead?

Edited by Buckeye

Share this post


Link to post
Share on other sites

 


EC' is the vector that I woudl like to find

 

 


it seems like I needed the negative one

 

You may want to check your vector math. The EC' vector as shown in the diagram (arrow pointing from E to C') would be formed as (C' - E). Are you perhaps using (E - C') instead?

 

yes i'm , in the geogebra I did that , but in my code I saw that and I fixed that .

and im really new in non-highschool math smile.png

Edited by MaorNr

Share this post


Link to post
Share on other sites

This topic is 1110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this