在线计算工具

1. 包的安装与使用 Octave是一个类似MatLab的在线计算工具。在Linux/Mac下还有命令行工具。这里我用Mac举例如下:

octave
pkg install -forge symbolic
pkg load symbolic
syms t p
syms
expr = cos(t)*cos(p)+sin(t)*sin(p)
simplify(expr)
expr = cos(t)sin(p)-sin(t)cos(p)
simplify(expr)


2. 四元数包 由于四元数包很老了,需要手动下载下来并解压,然后按照这里修改:

diff -ur quaternion.orig/src/is_real_array.cc quaternion/src/is_real_array.cc
--- quaternion.orig/src/is_real_array.cc	2019-01-02 13:53:40.766144030 -0500
+ −+++ quaternion/src/is_real_array.cc	2019-01-02 13:54:35.459444478 -0500
@@ -46,8 +46,8 @@
         {
             // args(i).ndims () should be always >= 2
             if (args(i).ndims () < 2
-                || ! ((args(i).is_numeric_type () && args(i).is_real_type ())
-                      || args(i).is_bool_type ()))
+                || ! ((args(i).isnumeric () && args(i).isreal ())
+                      || args(i).islogical ()))
             {
                 retval = false;
                 break;

然后重新压缩并用命令

octave
pkg install quaternion.tar.gz

安装。 使用举例

> i=quaternion(1,0,0)
i = 0 + 1i + 0j + 0k
> j=quaternion(0,1,0)
j = 0 + 0i + 1j + 0k
> k=quaternion(0,0,1)
k = 0 + 0i + 0j + 1k
> e1=[0 1;-1 0]
e1 =
 
   0   1
  -1   0
 
> e2=[0 i;i 0]
e2.w =
   0   0
   0   0
 
e2.x =
   0   1
   1   0
 
e2.y =
   0   0
   0   0
 
e2.z =
   0   0
   0   0
 
> e3=[0 j;j 0]
e3.w =
   0   0
   0   0
 
e3.x =
   0   0
   0   0
 
e3.y =
   0   1
   1   0
 
e3.z =
   0   0
   0   0
 
> e4=[0 k;k 0]
e4.w =
   0   0
   0   0
 
e4.x =
   0   0
   0   0
 
e4.y =
   0   0
   0   0
 
e4.z =
   0   1
   1   0
> e1*e2
ans.w =
   0   0
   0   0
 
ans.x =
   1   0
   0  -1
 
ans.y =
   0   0
   0   0
 
ans.z =
   0   0
   0   0

Leave a Reply

Your email address will not be published. Required fields are marked *