quaternionsrotate.htm
来自「电脑图学(Computer Graphics)是资料结构、演算法与数学的应用」· HTM 代码 · 共 303 行 · 第 1/2 页
HTM
303 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="css/stdlayout.css" type="text/css">
<link rel="stylesheet" href="css/print.css" type="text/css">
<meta content="text/html; charset=gb2312" http-equiv="content-type">
<title>四元数与旋转</title>
</head>
<body>
<h3><a href="http://caterpillar.onlyfun.net/GossipCN/index.html">From
Gossip@caterpillar</a></h3>
<h1><a href="ComputerGraphics.htm">Computer Graphics: 四元数与旋转</a></h1>
在讨论“四元数”之前,我们来想想对三维直角座标而言,在物体旋转会有何影响,可以扩充三维直角座标系统的旋转为三角度系统(Three-angle system),在Game Programming Gems中有提供这么一段:<br>
<br>
<div style="margin-left: 40px;"><span style="font-weight: bold;">Quaternions
do not suffer from gimbal lock. With a three-angle(roll, pitch, yaw)
system, there are always certain orientations in which there is no
simple change to the trhee values to represent a simple local roation.
You often see this rotation having "pitched up" 90 degree when you are
trying to specify a local yaw for right.</span><br>
</div>
<br>
简单的说,三角度系统无法表现任意轴的旋转,只要一开始旋转,物体本身即失去对任意轴的自主性。<br>
<br>
四元数(Quaternions)为数学家Hamilton于1843年所创造的,您可能学过的是复数,例如:a + b i 这样的数,其中i *
i = -1,Hamilton创造了三维的复数,其形式为 w + x i + y j + z k,其中i、j、k的关系如下:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">i</span><sup style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sup><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> = j</span><sup style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sup><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> = k</span><sup style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sup><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> = -1</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">i * j = k = -j * i</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">j * k = i = -k * j</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">k * i = j = -i * k</span><br>
</div>
<br>
<span class="postbody"></span>假设有两个四元数:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">q</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">1</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> = w</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">1</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> + x</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">1</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> i + y</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">1</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> j + z</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">1</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> k</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">q</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> = w</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> + x</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> i + y</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> j + z</span><sub style="font-weight: bold; font-family: Courier New,Courier,monospace;">2</sub><span style="font-weight: bold; font-family: Courier New,Courier,monospace;"> k</span><br>
</div>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?