Computational geometry handout--cross product (i)

Source: Internet
Author: User

This article will introduce a basic and important tool in computational geometry-the cross product.

Before we do that, we need to solve some basic problems first.

Code representation of points and segments

The knowledge of a struct or class is well understood here, but how it is written in the specific coding process, based on the individual's great flexibility.

For example, for points, it can be expressed in the following statement:

struct POINT

{

Double x, y;

}

For line segments, you can express them in the following statement:

struct line

{

Point A, B;

}

In fact, whether it is LRJ's "training Guide" or a Zongwan "algorithm problem combat strategy" will be mentioned in the actual problem we use the vector as a data structure is actually more convenient, this sentence is a summary of the words, need to programmers with experience of the growth will have a profound experience.

For vectors, the following statement:

struct vector

{

Double x, y;

}

Introduction of the concept of cross product

In order to measure the tilt state of a straight line in the plane, we introduce the concept of inclined angle. By establishing tanα= K in a Cartesian coordinate system, we realize the connection between geometric relations and algebraic relationships, which in fact is a core of solving geometrical problems with computers, and the computer is doing numerical operations, so what you need to do is to express the relations in algebraic relation. In space, in order to indicate the degree of inclination of a plane relative to the spatial Cartesian coordinate system, we measure it by a normal vector of the plane perpendicular to it (as this translates into a problem that describes the degree of linear tilt).

Definition of cross product:

Note that the θ here is based on the order of the right-hand rule and the cross-multiplication, which has a certain directivity, which directly leads to the wide application of the fork multiplication in the computational geometry problem.

Through this definition, we can easily get the following operation law.

Obviously this definition we do not like, because it is still too low in algebra, mainly because the sine of the angle is not easy to find, but this does not affect the definition of the importance of the application, the following problem we need to solve is to find an equivalent algebraic degree of a higher definition.

Determinant formula for cross-product (take two dimensions as an example):

In fact, we can see here that if we are using a directional line to do the cross-multiplication of the vector, then according to the definition, we will be writing 8 variables (the interested students can fully implement the process to see how troublesome), which is too cumbersome for programmers, We therefore advocate the representation of line segments in plane geometry in the form of vector vectors.

The reason why the cross-multiplication is so detailed is that it has all kinds of important applications in the back.

Application of cross product

One: solves the area of the triangle (parallelogram).

So when we give the triangle three point coordinates, we can calculate the area of the triangle directly by using the fork multiplication, and the result is more accurate (reduce the number of open radical) by using the Helen formula.

Based on this conclusion, we can derive the calculation formula of any n-side-shape area.

It is necessary to fully understand the ① formula given above on the definition of cross-product, that is, strictly speaking, using a fork to calculate the area can also be calculated negative. In this figure, we calculate the area of the polygon in this way:

Two: Point positioning.

From the above-mentioned ①, we can qualitatively describe the position relationship between the vector by the algebraic formula and the correspondence between the sine of the angle and the outcome.

This qualitative description, in the subsequent calculation of the chaos of the algorithm will be frequent, including to determine whether the intersection of segments, polar order, convex hull problems and so on, so it must be understood thoroughly.

Computational geometry handout--cross product (i)

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.