49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // This Source Code Form is subject to the terms of the Mozilla Public
 | |
| // License, v. 2.0.If a copy of the MPL was not distributed with this
 | |
| // file, You can obtain one at https ://mozilla.org/MPL/2.0/.
 | |
| 
 | |
| #include "AngleAxis.h"
 | |
| 
 | |
| template <typename T>
 | |
| AngleAxis<T>::AngleAxis() {
 | |
|   this->angle = AngleOf<T>();
 | |
|   this->axis = Direction<T>();
 | |
| }
 | |
| 
 | |
| template <typename T>
 | |
| AngleAxis<T>::AngleAxis(AngleOf<T> angle, Direction<T> axis) {
 | |
|   this->angle = angle;
 | |
|   this->axis = axis;
 | |
| }
 | |
| 
 | |
| template <typename T>
 | |
| AngleAxis<T>::AngleAxis(float angle, Vector3 axis) {
 | |
|   this->angle = AngleOf<T>(angle);
 | |
|   this->axis = Direction<T>(axis);
 | |
| }
 | |
| 
 | |
| template <typename T>
 | |
| AngleAxis<T>::AngleAxis(Quaternion q) {
 | |
|   float angle;
 | |
|   Vector3 axis;
 | |
|   q.ToAngleAxis(&angle, &axis);
 | |
|   this->angle = AngleOf<T>(angle);
 | |
|   this->axis = Direction<T>(axis);
 | |
| }
 | |
| 
 | |
| template <typename T>
 | |
| Quaternion AngleAxis<T>::ToQuaternion() {
 | |
|   Vector3 axisVector = this->axis.ToVector3();
 | |
|   float angleFloat = this->angle.ToFloat();
 | |
|   Quaternion q = Quaternion::AngleAxis(angleFloat, axisVector);
 | |
|   return q;
 | |
| }
 | |
| 
 | |
| template <typename T>
 | |
| Direction<T> AngleAxis<T>::GetSwing() {
 | |
|   return this->axis;
 | |
| }
 | |
| 
 | |
| template class AngleAxis<float>;
 | |
| template class AngleAxis<signed short>;
 |