[Learning Notes] Computational geometry basics

Source: Internet
Author: User
Tags cos

Trigonometric function

Vector

The amount of magnitude and direction in a linear space.

Coordinate representation: $P (X_1,y_1), Q (x_2,y_2) $.

$\overrightarrow{pq}= (x_2-x_1,y_2-y_1) $.

$| pq|=\sqrt{(x_2-x_1) ^2+ (y_2-y_1) ^2}$.

Vector operations

$a = (x_1,y_1), b= (x_2,y_2) $.

    • Addition

$a +b= (x_1+x_2,y_1+y_2) $.

    • Subtraction

$a-b= (x_1-x_2,y_1-y_2) $.

    • Point multiplication

$a \;\cdot\;b=x_1x_2+y_1y_2$.

$a \;\cdot\;b=|a| | b|cos<a,b>$

Application: To find the angle between two vectors to determine whether vertical ($cos 90$°$=0$).

    • Fork Multiply

$a \;\times\;b=x_1y_2-x_2y_1$.

$|a\;\times\;b|=|a| | b|sin<a,b>$.

$a \;\times\;b=0$, common line.

Judging line segment Intersection

$ (ac\;\times\; AD) (bc\;\times\; BD) \;\leq\;0$ and $ (ca\;\times\; CB) (da\;\times\;D b) \;\leq\;0$.

Vector rotation

The $ A (x_1,y_1) $ counter-clockwise rotation $\theta$ (radians) gets $b (X_1cos\theta-y_1sin\theta,x_1sin\theta+y_1cos\theta) $.

$P. s.$ only change direction (length unchanged). Memory method: Rotate $\pi/2$ to get the result $ (-y_1,x_1) $.

Three-point co-line

The angle is $0$ and $a\;\times\;b=0$.

Whether the point is on the ray

The angle is $0$ and the point multiplication $\geq\;0$.

$<0$, Reverse!

Polygon Area

Set the polygon vertices to $p_1,p_2,..., p_n$ in turn.

$\large{s=|\frac{\sum_{i=1}^{n-1}\overrightarrow{op_i}\times\overrightarrow{op_{i+1}}+\overrightarrow{op_n}\ times\overrightarrow{op_{1}}}{2}}|$.

Point to line perpendicular

Point to line perpendicular $d,ed\;\perp\; ab$.

Rotate the $\overrightarrow{ab}\pi/2$.

Straight line intersection.

The position relationship of the circle

$d $ is the center distance of two circles, $R, the R $ is two circle radius respectively.

$d >r+r$ away from the outside;

$d =r+r$ and circumscribed;

$| r–r|<d<r+r$ intersect;

$d =| r–r|$ inner cut;

$d <| r–r|$ included.

Whether the point is within a convex polygon

Random Ray

Recommended

http://dev.gameres.com/Program/Abstract/Geometry.htm# to determine whether a point is in a polygon

[Learning Notes] Computational geometry basics

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.