|
|
Le 14/08/2012 18:12, Leroy nous fit lire :
> Le_Forgeron wrote:
>> Le 14/08/2012 04:30, Leroy a écrit :
>>> Hay,
>>>
>>> What is the easiest(fastest) way to calculate if a point is left or
>>> right from your position? Given just two vectors the one your at and the
>>> one you want to check. While using <0,0,0> & your position vector for
>>> the direction your 'looking at'.
>>>
>>> A
>>> /
>>> 0---at-
>>> \
>>> B
>>
>> Is that 2D or 3D ?
> Yes :)
> I got into the habit of working out problems like this in 2d the
> expanding the solution to 3D. For most things 2D acts like a plane in 3D.
>
>>
>> V1: vector/point you are looking at from origin.
>> V2: vector/relative position of a point X from origin
>>
>> in 3D:
>> You are missing at least another vector to define the "up".
> Your Right! Another habit of using Y as 'up' everywhere.
>> If your vector V1 was not a direction you are looking at, but the
>> oriented normal of the splitting plane, you would have enough data (and
>> could use the solution of 2D). Vector N is the dot product of V1 and Up.
>>
> Lets see, I have played around with normals and planes. Its a point
> perpendicular to a plane at <0,0,0>,it defines a plane in POV. I have no
> idea what the 'splitting plane' is! I think you mean the plane dividing
> left and right.
Correct.
> The dot product of (V1,Up) is a float!? I don't
> understand 'Vector N'.
My bad. it is the cross product of N := V1 x Up
I have inversed the whole naming (not native English)
>
>> in 2D:
>> I assume you are at <0,0>, and you are looking at V1, left or right for
>> X is best computed as the sign of the cross product.
> This probably is the answer I was thinking of when I asked the question!
You want to know the projection of V2 on N. (only the sign) of the dot
product N . V2
So compute (V1 x Up) . V2
(or whatever order you want. V2 . ( Up x V1 ), there is 2 additional
permutations, also valid (but the resulting sign might change, so stick
to one formula once chosen))
x : cross product (give a vector)
. : dot product (give a scalar)
The sign is a local convention, there is no way to define left & right
on transmission with an alien of a remote universe.
Post a reply to this message
|
|