如何计算 3D 圆的切线?

发布于 2024-11-05 18:32:50 字数 678 浏览 2 评论 0原文

我需要帮助来计算 3D 空间中圆的切线,这是我到目前为止所拥有的 在此处输入图像描述

在此处输入图像描述

切线由蓝线表示,这是我从朋友那里得到的计算它们的方法

Vec3D getTangentBetweenTwoPoint( Vec3D p1, Vec3D p2 ) {
Vec3D r = new Vec3D( p1.x - p2.x,
                     p1.y - p2.y,
                     p1.z - p2.z );
  r.normalize();
  return r;
}

void getTangents() {
  Vec3D p0, p1;
  for ( int i = 1; i < curve_length + 1; i++ ) {
    p0 = points[i % curve_length];
    p1 = points[(i+1) % curve_length];
    tangents[i % curve_length] = getTangentBetweenTwoPoint( p0, p1 );
  }
}

任何帮助将不胜感激

I need help to calculate the tangets of a circle in 3D space, this is what I have so far
enter image description here

enter image description here

Tangents are represented by the blue lines, and this is the method I got from a friend to calculate them

Vec3D getTangentBetweenTwoPoint( Vec3D p1, Vec3D p2 ) {
Vec3D r = new Vec3D( p1.x - p2.x,
                     p1.y - p2.y,
                     p1.z - p2.z );
  r.normalize();
  return r;
}

void getTangents() {
  Vec3D p0, p1;
  for ( int i = 1; i < curve_length + 1; i++ ) {
    p0 = points[i % curve_length];
    p1 = points[(i+1) % curve_length];
    tangents[i % curve_length] = getTangentBetweenTwoPoint( p0, p1 );
  }
}

Any help will be much appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街道布景 2024-11-12 18:32:50

基本上,您可以找到从需要切线的点到圆心的向量,并取该向量与圆法线的叉积(通过取圆的 2 个点加上圆心得到,结果为平面方程)。

如果对该叉积进行归一化,您将获得该点的法线/切线向量。

Basically, you'd find the vector from the point you need the tangent for to the circle's center and take the cross product of that vector as well as the circle's normal (which you get by taking 2 points of the circle plus the center resulting in a plane equation).

If you normalize that cross product you get the normal/tangent vector for that point.

不美如何 2024-11-12 18:32:50

在代码中将 i 替换为 i-1 :

p0 = points[(i-1) % curve_length];

我假设您的点在圆上等距分布,因此前一个点和下一个点之间的线将平行于当前点的切线。

Replace i with i-1 in your code here:

p0 = points[(i-1) % curve_length];

I am assuming your points are equally spaced on the circle, so the line between the previous point and the next point will be parallel to the tangent at the current point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文