- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我在 3d 空间中有一个实体,并且我知道它的位置向量 (x, y, z) 和它的速度向量(因此它在空间中的方向)。
从已知点A出发,我想分两步到达已知点B:
a) 沿着已知半径 R 的圆形路径转弯,直到点 C
b) 从 C 点直行到终点 B。
速度(标量值)并不重要。速度(矢量)是已知的,所以我想它应该定义圆所在的平面,与其相切,以及 A 和 B 之间的线...
我想知道如何找到 C 的坐标 (x, y, z) 和那里实体的速度向量。
最佳答案
如果我没理解错的话,你的情况(在包含A、B、v的平面)如下图所示。给定了点 A 和 B,以及矢量 v 和距离 r。你想找到 C 点。
好吧,设向量w = (−v̂y, v̂x) 是垂直于v< 的单位向量/强>。那么 O = A + r w。
现在,|C − O| = r 和 (C − B)·(C − O) = 0(其中·是点积)。将这些组合起来得到一个二次方程,您可以求解该方程以找到 C 的两个可能位置。然后选择 (C − B)×(C − O) 符号正确的那个。
(圆心还有第二种选择,O = A − r w,代表顺时针转而不是逆时针转。这给了你另一种可能C .我猜你将不得不使用一些启发式来决定你喜欢哪一个:也许是具有最小∠AOC 的那个。)
St0rM 请求帮助以 3D 方式执行此操作(请参阅评论)。这很容易!包含 A、B 和 v 的平面具有法向量 n = (A − B) × v。设 u = n × v 是垂直于 n 和 v 的向量, 并令 w = û(u 方向的单位向量)。
您还需要考虑 C 与 A 位于同一平面的约束:C·n = A.n,并且“右(C − B)×(C − O)的符号”变为“(C − B)×(C − O)·n的正确符号”。
求解这个方程组有困难吗?
好吧,如果 (C − B)·(C − O) = 0,则 (C − O + O − B)·(C − O) = 0,因此 (C − O)·(C − O ) + (O − B)·(C − O) = 0,因此 C·(O − B) = O·(O − B) − r2。
您会注意到这是一个平面方程,C·n = A.n 也是如此。将这两个平面相交(see Wikipedia for details — 您可以使用更简单的解决方案,因为这些平面是正交的并且可以很容易地成为正交平面)以获得 C 所在的直线的方程:C = H + λL,例如,其中 L = n×(B-O)。然后用 (C − O)·(C − O) = r2 将其转化为 λ 的二次方程。如果将直线方程重写为 C = H + λL + O,从而消除出现的“- O”,您会发现二次方程会大大简化。
这是使用 numpy
进行向量代数运算的 Python 实现。我相信您能弄清楚如何将其转换为您选择的语言。
import math
from numpy import cross, dot
from numpy.linalg import norm
def unit(v):
"""Return a unit vector in the same direction as v."""
return v / norm(v)
def turnpoints(A, B, v, r):
"""Generate possible turning instructions for a path from A to B
that starts out in direction v, turns through part of a circle of radius
r until it reaches a point C (to be determined), then heads straight for
B. Return each instruction in the form (sense, C) where sense is -1 for
clockwise and +1 for anticlockwise."""
n = unit(cross(A - B, v)) # Unit normal to plane containing A, B, v.
w = unit(cross(n, v)) # Unit normal to v lying in that plane.
for sense in (-1, +1): # Turn clockwise or anticlockwise?
O = A + sense * r * w # Centre of turning circle.
BB = B - O
m = unit(BB)
# C lies on the line H + l*L + O
H = dot(A, n) * n + (r**2 / norm(BB)) * m
L = cross(n, m)
# |C - O| = r**2 gives quadratic eqn in l with coefficients a=1, b=0, c.
c = dot(H, H) - r**2
disc = - 4 * c # Discriminant of quadratic eqn.
if disc < 0:
continue # No tangents (B inside circle).
elif disc == 0: # One tangent (B on circle).
C = H + O
yield (sense, C)
else: # Two tangents (B outside circle)
for sign in (-1, +1):
l = sign * math.sqrt(disc) / 2
C = H + l * L + O
# Only one choice for C is correct (the other involves
# reversing direction).
if dot(cross(C - B, C - O), n) * sense > 0:
yield (sense, C)
关于math - 在给定初始和最终位置以及起始速度向量的情况下,在 3d 空间中查找路径上的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6550493/
考虑需要与 iOS 5 和 iOS 6 兼容的应用。 有没有办法标记纯粹为了 iOS 5 兼容性而存在的代码,以便当部署目标最终更改为 iOS 6 时它显示为编译错误(或警告)? 像这样: #IF_D
我想我知道答案但是...有什么方法可以防止全局变量被稍后执行的 修改吗? ?我知道全局变量首先是不好的,但在必要时,有没有办法让它成为“最终”或“不可变”?欢迎黑客/创造性的解决方案。谢谢 最佳答案
class Foo { final val pi = 3 } 是否每Foo对象有一个 pi成员?因此我应该把 pi在伴生对象中? 最佳答案 如果您担心内存占用,您可以考虑将此字段移动到伴随对象中。
随着可用的 Web 开发框架种类繁多,似乎总是有一种“尝试新事物”的永久动机。因此,我们中的一些人发现自己用一个框架换另一个框架,从来没有对最终结果完全满意。当然,总会有一个特定的 Web 框架可以完
在MDN中指出, If the finally block returns a value, this value becomes the return value of the entire try
我正在尝试用 JavaScript 制作一个基本的井字棋类型游戏。尽管 x 和 y 值在 if 语句的范围内,但除最后一个之外的所有空格都有效。 我不知道为什么最后的 else if 语句不起作用。
我想知道如何使用PowerMock模拟kotlin最终类(class),以便进行测试。我按照指南测试了Java最终类,但仍然出现此错误 Cannot subclass final class 有什么办
考虑以下设置: // debugger class public class Debug { // setting public final static boolean DEBUG
给定以下类(class): public class SomeClass { private final int a; public SomeClass(int a) {
This question already has answers here: What does “final” do if you place it before a variable?
我有一个类PasswordEncryptor,它使用org.jasypt.util.password.StrongPasswordEncryptor作为其字段之一,因为我试图使应用程序“可集群”所有类
我今天有一个关于 StreamReader 类的问题。具体使用文件名参数初始化此类例如: TextReader tr = new StreamReader(fileName); 显然,当此操作完成后,
我想弄清楚什么是使用带锁的 try/finally 的最佳方式。 当我在同一个地方有 lock() 和 unlock() 时,我只使用 try/finally block 作为 JavaDoc还建议:
在 Java 中序列化后是否可以将 final transient 字段设置为任何非默认值?我的用例是一个缓存变量——这就是它是 transient 的原因。我还有一个习惯,就是制作不会改变的 Map
在this问题说 final transient 字段在序列化后不能设置为任何非默认值。那么,为什么我为 aVar1 变量设置了 3,为 aVar3 变量设置了 s3? import java.io.
在Xbox上进行开发时,我使用的是F#规范中最终工作流程的修改版。 Xbox上的.net框架似乎不支持尾部调用。因此,我必须在编译时禁用尾部调用优化。 尽管起初看来这种限制会阻止在计算表达式中使用任何
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我想让我的带有自定义对象的ArrayList成为最终对象,以便对象在设置后无法更改。 我试图这样声明它: private final ArrayList XML = new ArrayList();
我有一个场景,我需要类似于 .NET 的 try-catch-finally block 的内容。 在我的尝试中,我将创建一个#temp表,向其中插入数据并基于#temp处理其他数据集。 先是CATC
对此可能有一个简单的答案,但尝试充分使用 Butterknife,将一些 findViewById 转换为 @BindViews,并注意到我无法在需要声明为 Final 的 View 上使用 Bind
我是一名优秀的程序员,十分优秀!