ft: 5,6.1: sphere class + normals

This commit is contained in:
djaidjai committed 2026-04-15 13:32:42 +02:00
1 parent 67c1eb861d
commit ebf39d014b
8 files changed
+126 -12

No files matched your search

+14 -7
View File
@@ -46,15 +46,11 @@ impl Vec3 {
(self.r * self.r + self.g * self.g + self.b * self.b) as f32
}
pub fn dot(self, other: Vec3) -> Vec3 {
Vec3 {
r: self.r * other.r,
g: self.g * other.g,
b: self.b * other.b,
}
pub fn dot(&self, other: &Vec3) -> f32 {
self.r * other.r + self.g * other.g + self.b * other.b
}
pub fn cross(self, other: Vec3) -> Vec3 {
pub fn cross(&self, other: &Vec3) -> Vec3 {
Vec3 {
r: self.g * other.b - self.b * other.g,
g: self.b * other.r - self.r * other.b,
@@ -142,6 +138,17 @@ impl AddAssign<f32> for Vec3 {
};
}
}
impl Sub<&Vec3> for Vec3 {
type Output = Self;
fn sub(self, rhs: &Self) -> Self {
Self {
r: self.r - rhs.r,
g: self.g - rhs.g,
b: self.b - rhs.b,
}
}
}
impl Sub<Vec3> for Vec3 {
type Output = Self;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.