在三角形平面上创建与另一个正交的线段 [英] Create a segment orthogonal to another one on a triangle plane

查看:125
本文介绍了在三角形平面上创建与另一个正交的线段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试实现类似定律的CSG算法.
基本任务是分割多边形,使它们不相交.

现在剩下要做的就是分割多边形,在纸上我知道该怎么做,在代码中要困难一些.

下垂吧,我们有一个三角形,当然是在平面上.
三角形内有一个(相交)线段,不接触边界或顶点.

我现在需要两件事:
-一种将正交线段获取到现有线段的算法,以便它们形成十字形.我做的事情与Laidlaw-Paper稍有不同(我不太了解),这就是为什么我需要正交线段的原因.
-一种确定点是否在线段的一侧(或穿过线段点的无限线)或另一侧的算法.
记住:每个点都在三角形平面上.因此,当我说正交时,我的意思不是指向平面之外.

对于上一个,我已经做了一些操作,但是我不确定它是否可以正常工作,它通过了我所做的视图测试,但是应用它时的结果有点令人困惑.

I am currently trying to implement a laidlaw-like CSG algorithm.
The essential task is to split polygons so they dont intersect.

Only thing for me left to do now is to split the polygons, on paper I know how to do it, in code it is a little more difficult.

Let''s sag we have a single triangle, of course lying on a plane.
Within the triangle there is a (intersection) segment, not touching the boundary or a vertex.

I need two things now:
- An algorithm to get an orthogonal Segment to the existing one so they are forming a cross. I''m doing things a little different than in the Laidlaw-Paper (I didn''t understand completely), which is why I need the orthogonal segment.

- An algorithm to determine if a point is on one side of the segment (or infinite line that goes through the segment points), or the other one.
Remember: EVERY point is on the triangle plane. So when I say orthogonal I don''t mean pointing out of the plane.

For the last one I already did something but I am not sure its working correctly, it passed the view test I have made, but the results when applying it are a bit confusing.

public static double WichSide(Segment3D seg, Vector3db P)
{
    Vector3db cp1 = Vector3db.Cross(seg.P1 - seg.P0, P - seg.P0);
    return Vector3db.Dot(new Vector3db(1,1,1), cp1);
}


我以为如果点P在右侧,则此函数给一些数字带负号,如果点P在左侧,则给它带正号.
Vector3db类非常类似于其中的任何Vector3类.


现在请,我不擅长数学,花了我数周时间才能到达我的位置,但我仍然不了解我正在使用的每种算法(我尝试过),因此请尽量保持答案简单: :

在此先感谢大家,
一月

加法:
显然,唯一不清楚的是我对细分的定义:
像在大多数3D应用程序中一样,我在这里指的是由两个三维点定义的线段.除了计算线段的方向之外,我的结构实际上不包含任何其他内容.

简而言之:
-有一个包含三角形的平面.
-在此三角形内,有一个从P0到P1的线段
-我想要的是线段P0-P1的正交段.
-此正交线段的每个点都必须位于三角形平面上(就像三角形和现有线段中的每个顶点一样).

我希望这会减少您的困惑,您必须找个借口.我不太熟悉英语中所有正确的数学术语.

哦,是的,我的Vector类包含所需的一切,例如叉积,点积,标量乘法和适当的运算符.

http://imageupload.org/pt-1212944275937.html -这是一个可以帮助您理解的图


I thought this function gave some number with a negative sign if the point P is on the right, and a positive one if its on the left.
The class Vector3db is pretty similar to any Vector3 class there is.


Now please, I am not good at math, it was took me weeks to get where I am and I still don''t understand every algorithm I am using (I try), so try to keep your answers as simple as possible :sigh:

Thanks in advance guys,
Jan

Addition:
Well apparently the only thing unclear was my defintion of segment:
Like in most 3D-Application I am refering to a line segment here which is defined by two three-dimensional points. My structure does not really contain anything else, other than calculating the line-segment''s direction.

So in short:
- There is a plane containing a triangle.
- Within this triangle there is a line-segment from P0 to P1
- What I want is an orthognal segment to the line-segment P0-P1.
- Every point of this orthogonal segment has to lie (like every vertex from the triangle and the existing line-segment) on the triangle plane.

I hope this confuses you less, and you have to excuse. I am not really familiar with all the correct mathematical terms in English.

Oh and yes, my Vector class contains everything needed, like cross product, dot product, multiplication with a scalar and the proper operators.

http://imageupload.org/pt-1212944275937.html - Here is a drawing that should help you understand

推荐答案

好的,另一个答案:
从您的图片中,我可以在一架飞机上看到所有物体.现在,我只会为您找到新线段的方向,您可以自己定义其位置/膨胀(我问过您所需的点位置).

您有由3个3D点定义的三角形:A,B,C,三角形为{A,B,C}.
您有可用的绿色细分:{G1,G2}; G *是3D点.我将使用大括号表示细分.

现在,我不知道您的向量是如何定义的,是什么操作.假设您可以通过两个3D点构造一个向量.

构建3D向量V1 = new Vector ({A, B})V2 = new Vector ({B, C}).
这样,V3 = V1×V2垂直于三角形平面.

现在,有一个基于可用绿色线段的向量:

Vg = new Vector({G1, G2})

新向量将与绿色向量Gv正交:

Vnew = Vg×V3

由于Vg与三角形位置正交且Vg在该位置,因此Vnew将再次位于平面中,但与绿色Vg正交.

当然,这是伪代码.我真的需要您所有的3D类来显示任何代码.

您有正确的方向.我尚不知道新细分受众群的必要位置和长度,但我想您可以找到自己的地方.

(如果您的图片具有启发性,并且视觉建议正确,则可以通过对起点和终点进行平均,并根据基础中的每个组成部分,将其移至绿色部分的中间.然后,这将定义新的中间部分
All right, another answer:
From your picture I can see all in one plane. For now, I''ll find you only the direction of new segment, you can define its position/dilation by yourself (I asked you about required position of points).

You have triangle defined by 3 3D points: A, B, C, triangle is {A, B, C}.
You have available green segment: { G1, G2 }; G* are 3D points. I will denote segments using curly brackets.

Now, I don''t know how your vectors are defined, what are the operation. Let''s assume you can construct a vector by two 3D point.

Build 3D vector V1 = new Vector ({A, B}), V2 = new Vector ({B, C}).
This way, V3 = V1×V2 is normal to triangle plane.

Now, have a vector based on available green segment:

Vg = new Vector({G1, G2})

New vector will be orthogonal to a green vector Gv:

Vnew = Vg×V3

As Vg is normal to the triangle place and Vg is in the place, Vnew will be again in the plane but orthogonal to the green Vg.

This is pseudo-code of course. I really need all your 3D classes to show any code.

You got correct direction. I don''t know yet the required position and length of new segment, but you can find out yourself, I think.

(If your picture is suggestive and the visual suggestion is correct, you can go to the middle of green segment by averaging of its start and end points, by each of the components in your basis separately. Then this will define a middle of your new segment.)


如果您有一个由两个向量A和B定义的平面;仅当它们之间的角度以及它们各自的长度不太接近零时,它们才实质上定义了平面方向.在这种情况下,您总是可以得到两个向量的乘积:

C = A×B

以这种方式计算出的C既与A和B正交,又与该平面正交.使用此技术,您可以进行进一步的计算以构建符合您要求的向量.
If you have a plane defined by two vectors A and B; they essentially define a plane orientation only if the angle between them, and the length of each are not too close to zero. In this case, you can always get a vector product of the two:

C = A×B

C calculated this way is orthogonal to both A and B and to the plane; using this technique you can do further calculations to build vectors with orientation to your requirements.


这篇关于在三角形平面上创建与另一个正交的线段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆