File tree 1 file changed +20
-10
lines changed
1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,18 @@ namespace qtnion{
60
60
ret.k = one * rhs.k + i * rhs.j - j * rhs.i + k * rhs.one ;
61
61
return ret;
62
62
}
63
+ /* *
64
+ * @brief 四元数の実数による除算
65
+ * @param rhs 除数
66
+ */
67
+ quaternion operator /(const T rhs) const {
68
+ quaternion ret;
69
+ ret.one = one/rhs;
70
+ ret.i = i/rhs;
71
+ ret.j = j/rhs;
72
+ ret.k = k/rhs;
73
+ return ret;
74
+ }
63
75
};
64
76
/* *
65
77
* @brief 四元数に対する共役
@@ -86,21 +98,19 @@ namespace qtnion{
86
98
* @return 引数の逆数
87
99
*/
88
100
template <typename T>
89
- quaternion<T> inverse (quaternion<T> val) {
90
- quaternion<T> buf=conjugate (val);
91
- const T ARG_NORM=squ_norm (val);
92
- buf.one /=ARG_NORM;
93
- buf.i /=ARG_NORM;
94
- buf.j /=ARG_NORM;
95
- buf.k /=ARG_NORM;
96
- return buf;
97
- }
101
+ quaternion<T> inverse (quaternion<T> val) {return conjugate (val)/squ_norm (val);}
98
102
/* *
99
103
* @brief 四元数に対するノルムを計算
100
104
* @return 自身のノルム
101
105
* @remark 二乗を求めたい場合、squ_normの方がよいと思われます。
102
106
* @see squ_norm()
103
107
*/
104
108
template <typename T>
105
- T norm (const quaternion<T> arg){return sqrt (arg.squ_norm ());}
109
+ T norm (const quaternion<T> arg){return sqrt (squ_norm (arg));}
110
+ /* *
111
+ * @brief 四元数の標準化をする
112
+ * @return もともとの値/それのノルム
113
+ */
114
+ template <typename T>
115
+ quaternion<T> normalize (quaternion<T> val) {return val/norm (val);}
106
116
}
You can’t perform that action at this time.
0 commit comments