简体   繁体   English

c# 从 3d position 获取对象的 2d plot 点、单位向量和维度

[英]c# get object's 2d plot points from 3d position, unit vectors, and dimensions

I have xml data which is output from a 3D CAD system.我有 xml 数据,它是来自 3D CAD 系统的 output。
I need to take the xml data and build 2d plot points from it.我需要获取 xml 数据并从中构建 2d plot 点。
In a nutshell, given 3d position, unit vectors, and dimensions of the object I need to generate 2d plot points from a flat plane, in my case from the elevation "front" view as well as the bottom view.简而言之,给定 3d position、单位向量和 object 的维度,我需要从平面生成 2d plot 点,在我的例子中是从立面“前”视图和底部视图。

I am looking for help or pointing me in the right direction for how to take the 3d global position values, unit vectors, and shape dimensions and generate 2d plot points for the shape, rectangles, polygons, etc.我正在寻求帮助或指出正确的方向,了解如何获取 3d 全局 position 值、单位向量和形状尺寸,并为形状、矩形、多边形等生成 2d plot 点。

Here is an explanation of my entire scenario for a better understanding of the practical application of it but not my intention to ask all of you to do my work for me just hoping for some direction.这是对我的整个场景的解释,以便更好地理解它的实际应用,但我并不打算让你们所有人为我做我的工作,只是希望得到一些指导。

The 3d CAD platform is being used to design the constructive framing of houses. 3d CAD 平台用于设计房屋的结构框架。 3d 房子框架

Wall framing layout for a wall with 9 studs in it.墙内有 9 个立柱的墙体框架布局。

在此处输入图像描述

Every piece of the framing is designed as a part.框架的每一块都被设计成一个部分。
Each part is represented by the following xml inside of the framing container, in this case a wall panel:每个部分由框架容器内部的以下 xml 表示,在本例中为墙板:

In this example we have a piece of wood (a standard 2x4)在这个例子中,我们有一块木头(标准 2x4)
So, I need to build 2d points from this somehow, which represent the elevation view of the 2x4 stud standing vertically in a wall.因此,我需要以某种方式从中构建 2d 点,它们代表垂直立在墙上的 2x4 立柱的立面图。

在此处输入图像描述

    <panel item_id="1E1" use="WALLPANEL" type="7" quantity="1" flength="120" fheight="97.1" fthick="3.5" length="120" height="97.1" thick="3.5">
    <position>
        <x x="1.000000000000" y="0.000000000000" z="0.000000000000" />
        <y x="0.000000000000" y="0.000000000000" z="1.000000000000" />
        <z x="0.000000000000" y="-1.000000000000" z="0.000000000000" />
        <p x="60.000000000000" y="-1.750000000000" z="0.000000000000" />
    </position>
    <struct type="wall" use="EXT">
        <route>
            <line type="line">
                <start x="60.000000000000" y="0.000000000000" z="-1.750000000000" />
                <end x="-60.000000000000" y="0.000000000000" z="-1.750000000000" />
            </line>
        </route>
        <layer order="0" use="FRAMING" mater="FRAME-4">
            <top_pleq a="0.000000000000" b="0.000000000000" c="1.000000000000" d="0.000000000000" />
            <bottom_pleq a="0.000000000000" b="0.000000000000" c="-1.000000000000" d="-3.500000000000" />
            <part type="piece" item_id="A" use="STUD" sect_code="2x4 S" nom_width="  1.5000" nom_height="  3.5000" mater="LUMBER" shape="RECT" length="92.625000">
                <position>
                    <x x="1.000000000000" y="0.000000000000" z="0.000000000000" />
                    <y x="0.000000000000" y="0.000000000000" z="1.000000000000" />
                    <z x="0.000000000000" y="-1.000000000000" z="0.000000000000" />
                    <p x="52.000000000000" y="94.125000000000" z="-1.750000000000" />
                </position>

My 2d result would be an array of 2d points representing the 2x4 piece.我的 2d 结果将是代表 2x4 块的 2d 点数组。

   struct point2D {
      float x {get;set;}
      float y {get;set;
  }
  point2D[] points2d = ......etc.

And, the values for the example piece would be:并且,示例片的值将是:

112,1.5 112,1.5
112,95.75 112,95.75
113.5,95.75 113.5,95.75
113.5, 1.5 113.5, 1.5

Thank you everyone for reading this and for any help you can provide.感谢大家阅读本文并感谢您提供的任何帮助。

You need to project all 3D points on the desired plane using orthogonal projection .您需要使用正交投影将所有 3D 个点投影到所需的平面上。 The result will not be clear because to do this right you need a Hidden Line Removal algorithm.结果将不清楚,因为要正确执行此操作,您需要隐藏线移除算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM