mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-05-31 05:08:12 +00:00
Extract length() to its own function
This commit is contained in:
parent
5ddc5e76dd
commit
86ea6e1701
1 changed files with 6 additions and 2 deletions
|
@ -238,8 +238,12 @@
|
|||
this.z = z;
|
||||
}
|
||||
|
||||
length() {
|
||||
return Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
|
||||
}
|
||||
|
||||
normalize() {
|
||||
const length = Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
|
||||
const length = this.length();
|
||||
|
||||
if (length != 0) {
|
||||
this.x /= length;
|
||||
|
@ -365,4 +369,4 @@
|
|||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue