Skip to content
Snippets Groups Projects
Commit 3e3148b6 authored by Francois Henrotte's avatar Francois Henrotte
Browse files

added SVector3.unit()

parent d7fa4bbe
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ class SVector3 { ...@@ -35,6 +35,7 @@ class SVector3 {
double n = norm(); if(n){ P[0] /= n; P[1] /= n; P[2] /= n; } double n = norm(); if(n){ P[0] /= n; P[1] /= n; P[2] /= n; }
return n; return n;
} }
SVector3 unit() const{ SVector3 y(*this); y.normalize(); return y; }
void negate() { P[0] = -P[0]; P[1] = -P[1]; P[2] = -P[2]; } void negate() { P[0] = -P[0]; P[1] = -P[1]; P[2] = -P[2]; }
// why both [] and (), why not // why both [] and (), why not
double &operator[](int i){ return P[i]; } double &operator[](int i){ return P[i]; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment