矢量数学,寻找坐标为2向量之间的平面 [英] Vector math, finding coördinates on a planar between 2 vectors

查看:237
本文介绍了矢量数学,寻找坐标为2向量之间的平面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想产生沿样条线一个3D管。我有样条曲线的坐标(X1,Y1,Z1 - X2,Y2,Z2 - 等),你可以在黄色图示见。在那些点我需要生成圆,其顶点是在稍后的体育场进行连接。圆圈需要垂直于花键的两条线段的角落,以形成正确的管。注意,段保持较低用于说明目的

I am trying to generate a 3d tube along a spline. I have the coördinates of the spline (x1,y1,z1 - x2,y2,z2 - etc) which you can see in the illustration in yellow. At those points I need to generate circles, whose vertices are to be connected at a later stadium. The circles need to be perpendicular to the 'corners' of two line segments of the spline to form a correct tube. Note that the segments are kept low for illustration purpose.

[显然我不能发表图片,请查看图像在此链接] http://img191.imageshack.us/img191/6863/18720019.jpg

[apparently I'm not allowed to post images so please view the image at this link] http://img191.imageshack.us/img191/6863/18720019.jpg

我尽可能能够计算每个环的顶点在每个点处的花键的,但它们都在相同的平面,即同一角度的。我需要他们旋转根据自己的腿。(其中A和B是到C为例)

I am as far as being able to calculate the vertices of each ring at each point of the spline, but they are all on the same planar ie same angled. I need them to be rotated according to their 'legs' (which A & B are to C for instance).

我一直在想这在下面的调查与思考:

I've been thinking this over and thought of the following:

  • 在两条线段可以看作是2向量(图中的A和B)
  • 的角(在illustraton C)是其中顶点的环需要被计算
  • 我需要找到平面上所有的顶点将位于
  • 然后我可以用这个平面(=载体?)来计算的中心点,这是C的新载体
  • 和使用发现它们的X,Y,Z半径*正弦和余弦

不过,我真的很困惑之本的数学部分。我读点的产品,但它返回一个标量,我不知道如何在这种情况下适用。

However, I'm really confused on the math part of this. I read about the dot product but that returns a scalar which I don't know how to apply in this case.

有人点我到正确的方向?

Can someone point me into the right direction?

举个位上的情况的详细信息:

[edit] To give a bit more info on the situation:

我需要构建一个缓冲的花车,其中-IN 3-组描述顶点位置,将被OpenGL ES的连接,赋予另一个缓冲区与指数形成的多边形。

I need to construct a buffer of floats, which -in groups of 3- describe vertex positions and will be connected by OpenGL ES, given another buffer with indices to form polygons.

为了让形状的管子,我首先创建的花车,其中-IN 3-组在3D空间中描述的控制点组成的数组。

To give shape to the tube, I first created an array of floats, which -in groups of 3- describe control points in 3d space.

然后沿与段密度可变的,我通过这些控制点来使用这些控制点来创建CatmullRom花键和花车的另一个​​数组的3-描述基团 - 同样的形式返回该功能在卡特莫尔Rom样条的顶点。

Then along with a variable for segment density, I pass these control points to a function that uses these control points to create a CatmullRom spline and returns this in the form of another array of floats which -again in groups of 3- describe vertices of the catmull rom spline.

在每一个顶点,我想创建顶点环,该环也可以在不同的密度(量平滑的每个环/顶点)。

On each of these vertices, I want to create a ring of vertices which also can differ in density (amount of smoothness / vertices per ring).

所有前顶点(控制点和那些描述卡特莫尔ROM样条)都将被丢弃。

All former vertices (control points and those that describe the catmull rom spline) are discarded.

只有形成管环的顶点将被传递到OpenGL中,这反过来将连接那些以形成最终的管

Only the vertices that form the tube rings will be passed to OpenGL, which in turn will connect those to form the final tube.

我尽可能能够创建catmullrom花键,并在它的顶点的位置创建环,但是,它们不是下述的花键路径的所有上的位面是在相同的角度,

I am as far as being able to create the catmullrom spline, and create rings at the position of its vertices, however, they are all on a planars that are in the same angle, instead of following the splines path.

[/编辑]

谢谢!

推荐答案

假设你有一个参数曲线,如:

Suppose you have a parametric curve such as:

xx[t_] := Sin[t];
yy[t_] := Cos[t];
zz[t_] := t;  

其中给出:

Which gives:

的切线向量,以我们的曲线是通过在每个方向上的衍生物形成的。在我们的例子

The tangent vector to our curve is formed by the derivatives in each direction. In our case

Tg[t_]:= {Cos[t], -Sin[t], 1}  

正交平面上的向量来求解隐式方程:

The orthogonal plane to that vector comes solving the implicit equation:

Tg[t].{x - xx[t], y - yy[t], z - zz[t]} == 0  

在我们的例子中是:

-t + z + Cos[t] (x - Sin[t]) - (y - Cos[t]) Sin[t] == 0  

现在,我们找了一圈的那架飞机,中心在曲线。即:

Now we find a circle in that plane, centered at the curve. i.e:

c[{x_, y_, z_, t_}] := (x - xx[t])^2 + (y - yy[t])^2 + (z - zz[t])^2 == r^2  

解决两个方程,你得到的计算公式为界:

Solving both equations, you get the equation for the circles:

心连心!

修改

和画一个很大的圈子,你可能会得到一个(效率不高)管:

And by drawing a lot of circles, you may get a (not efficient) tube:

还是凭借良好的3D图形库:

Or with a good Graphics 3D library:

修改

既然你坚持:)这里是一个程序来计算圆的路口。

Since you insist :) here is a program to calculate the circle at junctions.

a = {1, 2, 3}; b = {3, 2, 1}; c = {2, 3, 4};
l1 = Line[{a, b}];
l2 = Line[{b, c}];

k = Cross[(b - a), (c - b)] + b; (*Cross Product*)
angle = -ArcCos[(a - b).(c - b)/(Norm[(a - b)] Norm[(c - b)])]/2;
q = RotationMatrix[angle, k - b].(a - b);
circle[t_] := (k - b)/Norm[k - b] Sin@t + (q)/Norm[q] Cos@t + b;

Show[{Graphics3D[{
    Red, l1,
    Blue, l2,
    Black, Line[{b, k}],
    Green, Line[{b, q + b}]}, Axes -> True],
  ParametricPlot3D[circle[t], {t, 0, 2 Pi}]}]

修改

在这里,你必须通过这种方法构建的网格。它不是pretty的,恕我直言:

Here you have the mesh constructed by this method. It is not pretty, IMHO:

这篇关于矢量数学,寻找坐标为2向量之间的平面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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