"Algorithm" calculates geometry

Source: Internet
Author: User
Tags cos

Slope

K=δy/δx

The slope is 0 o'clock and the line is parallel to the x-axis (δy=0).

★ The line is parallel to the y-axis (δx=0) when the slope does not exist.

Two points determine a line, so you only need to enumerate any two points when enumerating the slopes.

eg. enumerate the points on the same line, using the principle that the point on the same line must be on a straight line consisting of two points, simply enumerate any two points, and then enumerate whether the 3rd is in that line, and the Complexity O (1/6*n^3).

Enumeration of how many straight lines in a point, the use of the intersection of the same point must pass through the two lines of the principle of intersection, directly enumerate the two straight lines and then enumerate the third bar.

Vector

The vector is the point on the representation.

Dot Product: The product of two vector lengths multiplied by the cosine of their angle. (Results are numeric)

Dot (A) =len (A) *len (B) *cos (θ)

in a planar coordinate system, Dot (A, b) =xaxb+yayb.

The dot product is 0 o'clock, the two vectors are perpendicular, that is, the two vectors are perpendicular and only when xaxb+yayb=0.

Vector Length: Len (A) =sqrt (Dot (a,a)).

Vector angle: Angle (A, b) =cos (Dot (b)/len (A)/len (A)).

Cross product: Two vectors consisting of a triangular twice times the direction of the area, or called parallelogram. (The result is a vector, temporarily not to understand the direction of the problem)

Cross (A, b) =xayb-xbya.

Cross product is directed, the direction depends on sin (θ), along the first vector a See, B on the left side of the cross product >0, otherwise <0.

In particular, if two vectors are collinear (parallel), the cross product equals 0. That is, two vectors parallel and only if xayb-xbya=0.

Therefore, the cross product does not satisfy the Exchange law.

Application: Reference from--Computational geometry basis--"The usefulness of dot product and cross product"

1: Through the positive and negative judgment of the results between the two vectors of the cis-counterclockwise relationship

2: Judge the zigzag turn, can be converted to judge the 3rd in the first two forming a straight line counterclockwise direction, and then judge the turn.

3: Judge a point on the side of a straight line, the same way as above.

4: Determine whether the point is on the line segment, you can use the cross-multiplication first to determine whether collinear, and then determine whether on it.

5: Determine whether the two lines intersect (cross-Test): According to the point of judgment in the straight side of the line we can judge a line of two points on the other side of the line, and then the other line of the same judgment on the OK.

Vector Rotation:

X ' =xcosa-ysina

Y ' =xsina+ycosa

"Algorithm" calculates geometry

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.