mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-06-19 14:32:10 +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;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
length() {
|
||||||
|
return Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
|
||||||
|
}
|
||||||
|
|
||||||
normalize() {
|
normalize() {
|
||||||
const length = Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
|
const length = this.length();
|
||||||
|
|
||||||
if (length != 0) {
|
if (length != 0) {
|
||||||
this.x /= length;
|
this.x /= length;
|
||||||
|
@ -365,4 +369,4 @@
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue