0
votes

Here is a image:

enter image description here

I have two vectors : os, oe

the range between them is always from os (start) to oe (end).

So in this image the range between is a angle of 270°.

Then I have two vector to check: oa, ob

As you can see the vector oa should be within the range formed by osoe and the vector ob should be outside.

I am wondering if there is a way to do the check using only vector math (such as cross product dot product).

I tried to use cross product with clockwise/counter clockwise check but it seems like when the angle in between is larger then 180°, things get complex.

Any advice will be appreciated, thanks :)

1
This isn't a stackoverflow question as it is completely unrelated to programming. It should be on This math site . Although it may not be received well there because duplicates. But might as well tryMatthew Ciaramitaro
By the way the cross product of two vectors on the two dimensional plane xy is never on the two dimensional plane xy. it's normal (perpendicular) to the plane, so you can't figure it out using cross product. You should just find the angle between the oa and both os and oe. that will tell you if its between them or outside of their rangeMatthew Ciaramitaro
I'm voting to close this question as off-topic because it is not about computer programming.Rory Daulton

1 Answers

5
votes

I denote vector to point p as op.

Calculate cross product

 c_se = cross(os, oe)

If c_se>=0 (angle in 0..180 range), then you have to check whether

cross(os, op) >= 0 AND cross(op, oe) >= 0

If c_se < 0 (angle in 180..360 range), then you have to check whether

NOT (cross(oe, op) >= 0 AND cross(op, os) >= 0)