mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Add dot product node (#2126)
* dot product node * dot product node * cross product node * formatting n deleted comments * name changed * name changed * cross product removed * Minor code style changes --------- Co-authored-by: hypercube <0hypercube@gmail.com>
This commit is contained in:
parent
1264ea8246
commit
79b4f4df7b
1 changed files with 13 additions and 0 deletions
|
@ -408,6 +408,11 @@ fn clone<'i, T: Clone + 'i>(_: (), #[implementations(&ImageFrame<Color>)] 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.);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue