You are on page 1of 17

Cross Product Operation:

Each point is represented by coordinates (x,y).


Example: P0 = x0,y0; P1 = x1,y1; P2 = x2,y2

Case-1: P0 is (0,0).
P0 = x0,y0; P1 = x1,y1; P2 = x2,y2;
In the below figure, P0 is (0,0).

Cross product: P1XP2 = determinant of (x1,x2) and (y1,y2).


Case-2: P0 is not (0,0).
P0 = x0,y0; P1 = x1,y1; P2 = x2,y2;
In the below figure, P0 is not (0,0).

Example:
Question-1: Apply cross product theorem.

We have to apply cross product theorem.

So, answer for question 1 can be obtained by calculating the cross


product.

Question-2: Apply cross product theorem.


So, answer for question 2 can be obtained by calculating the cross
product.
Question-3:
Do 2 line segments intersect?
Example: line segments intersect.

Examples: line segments do not intersect.


To find answer for 3rd questions, we have to check all the necessary
conditions.

We will be given with 4 points P1, P2, P3 and P4.


If they are parallel, they do not intersect. Even, if they are not
parallel, they might not intersect.

Case 1:
Find the direction of P3 with respect to P1P2 and direction of P4 with
respect to P1P2.
Direction means, whether in clockwise direction or anti-clockwise
direction?
P1P2 is anti-clock-wise for P3 and clockwise for P4. They are on
opposite sides and they have chance that they might intersect.

Find the direction of P1 with respect to P3P4 and direction of P2 with


respect to P3P4.
P1 (clockwise) and P2 (anti-clockwise) are on the opposite directions.

P1 and P2 are on the opposite directions of P3P4. P3 and P4 are on


the opposite directions of P1P2.
So, they intersect.

Case 2:
Let us consider the below case.
P1 is anti-clockwise and P2 is clockwise with respect to P3P4.

P3 and P4 are on the same directions with respect to P1P2.


So, they do not intersect.

Case 3: On the line


P2 is on the line of P3P4.

P3 and P4 are on opposite directions with respect to P1P2.


Direction of P2 is 0 with respect to P3P4.
Direction of P1 is anti-clockwise with respect to P3P4.

As direction of P2 is 0 and P1 is anti-clockwise, we can take direction


of P2 as clockwise and say they intersect.
Pseudocode:

You might also like