From babe357f11fefa058e571141168a1863565a2cd3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 6 Nov 2024 19:08:56 +0100 Subject: [PATCH] Prepare for making `Scalar` NaN-safe --- experiments/2024-10-30/src/math.rs | 6 ++++++ experiments/2024-10-30/src/model.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/experiments/2024-10-30/src/math.rs b/experiments/2024-10-30/src/math.rs index 1a3992649..f96a59e98 100644 --- a/experiments/2024-10-30/src/math.rs +++ b/experiments/2024-10-30/src/math.rs @@ -4,3 +4,9 @@ pub type Point = [Scalar; 3]; pub struct Scalar { pub inner: f64, } + +impl Scalar { + pub fn new(value: f64) -> Self { + Self { inner: value } + } +} diff --git a/experiments/2024-10-30/src/model.rs b/experiments/2024-10-30/src/model.rs index e8af44571..17d9a4d4f 100644 --- a/experiments/2024-10-30/src/model.rs +++ b/experiments/2024-10-30/src/model.rs @@ -13,7 +13,7 @@ pub fn model() -> anyhow::Result { [-0.5, 0.5, 0.5], // 6 [0.5, 0.5, 0.5], // 7 ] - .map(|point| mesh.vertex(point.map(|coord| Scalar { inner: coord }))); + .map(|point| mesh.vertex(point.map(Scalar::new))); [ [0, 4, 6], // left