Vector Cross Product

Source: Internet
Author: User

1. The cross product of P (x1, Y1) and Q (X2, Y2) is:
P × q = (x1 * y2-x2 * Y1 );
If the result is greater than 0, P is clockwise in Q.
If the result is <0, P is in the counterclockwise direction of Q.
Equals to collinearity
Determine whether a point is in the Triangle
Int isintriangle (INT X1, int Y1, int X2, int Y2, int X3, int Y3, int pedx, int Pedy)
{
Int sz1, sz2, sz3;
Sz1 = (x2-x1) * (pedy-y1)-(pedx-x1) * (y2-y1 );
Sz2 = (x3-x2) * (pedy-y2)-(pedx-x2) * (y3-y2 );
Sz3 = (x1-x3) * (pedy-y3)-(pedx-x3) * (y1-y3 );
If (sz1 <0 & sz2 <0 & sz3 <0)
{
Return 1;
}
Else if (sz1> 0 & sz2> 0 & sz3> 0)
{
Return 1;
}
Return 0;
}

3D:

P (x0, y0, z0), u (x1, Y1, Z1 );

P * u = <y0 * z1-y1 * z0,-x0 * Z1 + X1 * z0, x0 * y1-x1 * y0>

The result is a normal vector;

2. When vector forks and products are required, you should assume that you are in the left-hand or right-hand coordinate system, and then use handshakes.

(The thumb points to the desired vector direction. The other four fingers indicate the direction of Bending. The left-hand coordinate system is clockwise and the right-hand coordinate system is counterclockwise)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.