首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >获取多面体的表面积(3D对象)

获取多面体的表面积(3D对象)
EN

Stack Overflow用户
提问于 2010-02-28 17:14:31
回答 7查看 6.5K关注 0票数 12

我有一个3D表面(想想xy平面)。飞机可以倾斜。(想一想坡路)。

给定定义曲面的3D坐标列表(Point3D1XPoint3D1YPoint3D1ZPoint3D12XPoint3D2YPoint3D2ZPoint3D3XPoint3D3YPoint3D3Z等),如何计算曲面的面积?

请注意,我在这里的问题类似于在2D平面中寻找面积。在2D平面中,我们有一个定义多边形的点列表,使用这个点列表,我们可以找到多边形的面积。现在假设所有这些点都具有z值,以使它们在3D中升高以形成曲面。我的问题是如何找到3D曲面的面积?

EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2010-02-28 18:48:52

我支持a few answers,我认为它是正确的。但我认为最简单的方法--不管是2D还是3D,都是使用下面的公式:

代码语言:javascript
运行
复制
area = sum(V(i+1) × V(i))/2;

其中×vector cross

执行此操作的代码为:

代码语言:javascript
运行
复制
    public double Area(List<Point3D> PtList)
    {

        int nPts = PtList.Count;
        Point3D a;
        int j = 0;

        for (int i = 0; i < nPts; ++i)
        {
            j = (i + 1) % nPts;
            a += Point3D.Cross(PtList[i], PtList[j]);
        }
        a /= 2;
        return Point3D.Distance(a,default(Point3D));
    }

    public static Point3D Cross(Point3D v0, Point3D v1)
    {
        return new Point3D(v0.Y * v1.Z - v0.Z * v1.Y,
            v0.Z * v1.X - v0.X * v1.Z,
            v0.X * v1.Y - v0.Y * v1.X);
    }

请注意,解决方案不依赖于对x平面的投影,我认为这很笨拙。

你认为如何?

票数 4
EN

Stack Overflow用户

发布于 2010-02-28 17:46:18

既然你说它是一个多面体,那么stacker的链接(http://softsurfer.com/Archive/algorithm_0101/algorithm_0101.htm)也是适用的。

下面是我根据您的情况对C代码进行的大致C#翻译:

代码语言:javascript
运行
复制
// NOTE: The original code contained the following notice:
// ---------------------------------------
// Copyright 2000 softSurfer, 2012 Dan Sunday
// This code may be freely used and modified for any purpose
// providing that this copyright notice is included with it.
// iSurfer.org makes no warranty for this code, and cannot be held
// liable for any real or imagined damage resulting from its use.
// Users of this code must verify correctness for their application.
// ---------------------------------------
// area3D_Polygon(): computes the area of a 3D planar polygon
//    Input:  int n = the number of vertices in the polygon
//            Point[] V = an array of n+2 vertices in a plane
//                       with V[n]=V[0] and V[n+1]=V[1]
//            Point N = unit normal vector of the polygon's plane
//    Return: the (float) area of the polygon
static float
area3D_Polygon( int n, Point3D[] V, Point3D N )
{
    float area = 0;
    float an, ax, ay, az;  // abs value of normal and its coords
    int   coord;           // coord to ignore: 1=x, 2=y, 3=z
    int   i, j, k;         // loop indices

    // select largest abs coordinate to ignore for projection
    ax = (N.x>0 ? N.x : -N.x);     // abs x-coord
    ay = (N.y>0 ? N.y : -N.y);     // abs y-coord
    az = (N.z>0 ? N.z : -N.z);     // abs z-coord

    coord = 3;                     // ignore z-coord
    if (ax > ay) {
        if (ax > az) coord = 1;    // ignore x-coord
    }
    else if (ay > az) coord = 2;   // ignore y-coord

    // compute area of the 2D projection
    for (i=1, j=2, k=0; i<=n; i++, j++, k++)
        switch (coord) {
        case 1:
            area += (V[i].y * (V[j].z - V[k].z));
            continue;
        case 2:
            area += (V[i].x * (V[j].z - V[k].z));
            continue;
        case 3:
            area += (V[i].x * (V[j].y - V[k].y));
            continue;
        }

    // scale to get area before projection
    an = Math.Sqrt( ax*ax + ay*ay + az*az);  // length of normal vector
    switch (coord) {
    case 1:
        area *= (an / (2*ax));
        break;
    case 2:
        area *= (an / (2*ay));
        break;
    case 3:
        area *= (an / (2*az));
        break;
    }
    return area;
}
票数 11
EN

Stack Overflow用户

发布于 2010-02-28 17:46:56

你是说三维平面多边形的面积吗?

  1. http://softsurfer.com/Archive/algorithm_0101/algorithm_0101.htm
  2. http://local.wasp.uwa.edu.au/~pbourke/geometry/area3d/
  3. http://thebuildingcoder.typepad.com/blog/2008/12/3d-polygon-areas.html
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2350604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档