diff options
| author | Juan Linietsky | 2015-05-01 23:20:41 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-05-01 23:20:41 -0300 |
| commit | dda60296d81edaabfdb56f47a2c949b5dad283fb (patch) | |
| tree | b41e31cc4620689a1e91adf852d0926fc600607a /core/math/vector3.cpp | |
| parent | fb8b740fcb50dc38526b458af096b72d1303d3e5 (diff) | |
| parent | 61e90385f6cbeebb8d3d03c33078802c2fa11eda (diff) | |
| download | godot-dda60296d81edaabfdb56f47a2c949b5dad283fb.tar.gz godot-dda60296d81edaabfdb56f47a2c949b5dad283fb.tar.zst godot-dda60296d81edaabfdb56f47a2c949b5dad283fb.zip | |
Diffstat (limited to 'core/math/vector3.cpp')
| -rw-r--r-- | core/math/vector3.cpp | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index cf6fd9242..a3877eb9f 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -27,27 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "vector3.h" - +#include "matrix3.h" void Vector3::rotate(const Vector3& p_axis,float p_phi) { - Vector3 axis1 = cross(p_axis); - float l = axis1.length(); - if (l==0) - return; - axis1/=l; - Vector3 axis2 = axis1.cross(p_axis).normalized(); - - float _x = axis1.dot(*this); - float _y = axis2.dot(*this); - - float ang = Math::atan2(_x,_y); - - ang+=p_phi; - - *this=((axis1 * Math::cos(ang)) + (axis2 * Math::sin(ang))) * length(); - + *this=Matrix3(p_axis,p_phi).xform(*this); } Vector3 Vector3::rotated(const Vector3& p_axis,float p_phi) const { |
