1
Fork 0
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:
RGBCube 2023-12-18 15:26:41 +03:00
parent 5ddc5e76dd
commit 86ea6e1701
No known key found for this signature in database

View file

@ -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>