diff --git a/node-graph/gcore/src/ops.rs b/node-graph/gcore/src/ops.rs index 11705361..80715666 100644 --- a/node-graph/gcore/src/ops.rs +++ b/node-graph/gcore/src/ops.rs @@ -408,6 +408,11 @@ fn clone<'i, T: Clone + 'i>(_: (), #[implementations(&ImageFrame)] value: value.clone() } +#[node_macro::node(category("Math: Vector"))] +fn dot_product(vector_a: DVec2, vector_b: DVec2) -> f64 { + vector_a.dot(vector_b) +} + // TODO: Rename to "Passthrough" /// Passes-through the input value without changing it. This is useful for rerouting wires for organization purposes. #[node_macro::node(skip_impl)] @@ -471,9 +476,17 @@ mod test { let value = ValueNode(4u32).then(IdentityNode::new()); assert_eq!(value.eval(()), &4); } + #[test] pub fn foo() { let fnn = FnNode::new(|(a, b)| (b, a)); assert_eq!(fnn.eval((1u32, 2u32)), (2, 1)); } + + #[test] + pub fn dot_product_function() { + let vector_a = glam::DVec2::new(1., 2.); + let vector_b = glam::DVec2::new(3., 4.); + assert_eq!(dot_product(vector_a, vector_b), 11.); + } }