Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CircularBuffer Servo Terminal mbed Radio
Diff: Matrix.cpp
- Revision:
- 17:4ec59e8b52a6
- Parent:
- 12:a952bd74d363
--- a/Matrix.cpp Mon May 27 00:42:22 2013 +0000
+++ b/Matrix.cpp Mon May 27 03:31:58 2013 +0000
@@ -37,18 +37,31 @@
-vector3 vector3::unit() const
+vector3 vector3::operator/(const float f) const
{
vector3 r;
- float m = sqrt(x*x + y*y + z*z);
- r.x = x / m;
- r.y = y / m;
- r.z = z / m;
+ r.x = x / f;
+ r.y = y / f;
+ r.z = z / f;
return r;
}
+float vector3::norm() const
+{
+ return sqrt(x*x + y*y + z*z);
+}
+
+
+
+vector3 vector3::unit() const
+{
+ return (*this)/norm();
+}
+
+
+
void vector3::print(char* buf, unsigned int len)
{
snprintf(buf, len, "%.4f\t%.4f\t%.4f", x, y, z);