Computational Geometry

本文深入探讨了几何计算的基础,包括向量的叉乘、点乘和反正切函数。通过这些基本操作,可以解决如判断线段平行、计算三角形面积、确定点是否在直线或多边形内等问题。特别强调了处理特殊情况和浮点计算不精确性的注意事项。
摘要由CSDN通过智能技术生成

Prerequisites

  • Graph Theory
  • Shortest Path

Tools

This module discusses several algorithms that calculate various geometric properties, mostly based on only two operations described below: cross product and arctangent.

Cross Product

The cross product of u and v is written as u x v. Computationally, the cross product of two three-dimensional vectors u and v is the vector determinant of the following matrix (where ij, and k are unit vectors in the xy, and z directions respectively):

| i  j  k  |
| ux uy uz |
| vx vy vz |

That equation works out to:

(uyvz-vyu z)i + (uzvx-u xvz)j + (uxv y-uyvx)k

This definition can be used for vectors in two dimensions by using three-dimensional vectors with a z component of 0. The resulting vector will only have a z value.

The cross product has three properties:

  • The cross product of two vectors is perpendicular to both vectors.
  • The length of the cross product is equal to the product of:
    • the length of u,
    • the length of v, and
    • the sine of the angle between the vectors.

Of the two different directions that are perpendicular to both u and v, the direction the cross product points depends on whether u is ``to the right'' of v or ``to the left.''

Dot product

The dot product of two vectors u and v is a scalar written as u · v. Computationally, it is defined in three dimensions as: uxvx + u yvy + uzv z

The dot product is actually equal to the product of:

  • the length of u
  • the length of v
  • the cosine of the angle between u and v.

Presuming u and v are non-zero, if the dot product if negative, u and v make an angle greater than 90 degrees. If it is zero, then u and v are perpendicular. If u cdot v is positive, then the two vectors form an acute angle.

Arctangent

The arctangentfunction calculates the (an) angle whose tangent is its argument and generally returns a real number between -pi/2 and pi/2. An additional function in C, atan2, takes two arguments: a DELTA y

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值