77 geometry process

0 引言

记录几何方面的一些处理技术。

1 任意多边形面积计算:包含凸多边形和凹多边形

转载了JustDoIT 

https://www.cnblogs.com/TenosDoIt/p/4047211.html

附上代码

struct Point2d
{
    double x;
    double y;
    Point2d(double xx, double yy): x(xx), y(yy){}
};
 
//计算任意多边形的面积,顶点按照顺时针或者逆时针方向排列
double ComputePolygonArea(const vector<Point2d> &points)
{
    int point_num = points.size();
    if(point_num < 3)return 0.0;
    double s = points[0].y * (points[point_num-1].x - points[1].x);
    for(int i = 1; i < point_num; ++i)
        s += points[i].y * (points[i-1].x - points[(i+1)%point_num].x);
    return fabs(s/2.0);
}

2 平面直线的交点

https://www.jianshu.com/p/3468c9967fc7

3 直角坐标与球坐标的相互转化

https://www.cnblogs.com/hans_gis/archive/2012/11/21/2755126.html

4 在球上生成均匀的点

(1)正二十面体:一个20个face,12个vertice的图形

(2)格点数量公式

 

 viewpoints = 10*4^depth + 2;

(1)12 = 10*4^0 + 2

(2)42 = 10*4^1 + 2

(3)162 = 10*4^2 + 2

(4)642 = 10*4^3 + 2

(3) 老外写的资料

http://donhavey.com/blog/tutorials/tutorial-3-the-icosahedron-sphere/

(4) 基本思路

(1)根据当前模型尺寸定义正二十边形,包括12个顶点(vertices)和20个三角面片(triangles)

(2)访问每一个面片,对面片进行细分,subdivision

原文地址:https://www.cnblogs.com/ghjnwk/p/11280695.html