Small optimization on sphere
This commit is contained in:
parent
b75663feab
commit
3aea707982
2 changed files with 13 additions and 6 deletions
8
vec3.hpp
8
vec3.hpp
|
|
@ -58,7 +58,13 @@ struct vec3 {
|
|||
double length() const
|
||||
{
|
||||
return sqrt(x*x + y*y + z*z);
|
||||
}
|
||||
}
|
||||
|
||||
// Length squared, useful for some calculations
|
||||
double length_squared() const
|
||||
{
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
};
|
||||
|
||||
/* Type aliases */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue