Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more advanced math nodes #1383

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Add more advanced math nodes #1383

merged 1 commit into from
Aug 14, 2023

Conversation

isiko
Copy link
Contributor

@isiko isiko commented Aug 11, 2023

Added a few more mathematical operations as nodes. With this PR, all operations mentioned in #912 should be implemented + some other operations like rounding and the natural logarithm.

Operations Implemented by this PR:

  • Floor
  • Ceil
  • Round
  • Absolute Value
  • Logarithm
  • Natural Logarithm
  • sin
  • cos
  • tan

Comment on lines 86 to 142
// Floor
pub struct FloorParameterNode;

#[node_macro::node_fn(FloorParameterNode)]
fn floor(input: f32) -> f32 {
input.floor()
}

// Ceil
pub struct CeilParameterNode;

#[node_macro::node_fn(CeilParameterNode)]
fn ceil(input: f32) -> f32 {
input.ceil()
}

// Round
pub struct RoundParameterNode;

#[node_macro::node_fn(RoundParameterNode)]
fn round(input: f32) -> f32 {
input.round()
}

// Absolute Value
pub struct AbsoluteParameterNode;

#[node_macro::node_fn(AbsoluteParameterNode)]
fn abs(input: f32) -> f32 {
input.abs()
}

// Log
pub struct LogParameterNode<Second> {
second: Second,
}

#[node_macro::node_fn(LogParameterNode)]
fn ln<U: num_traits::float::Float>(first: U, second: U) -> U {
first.log(second)
}

// Natural Log
pub struct NaturalLogParameterNode;

#[node_macro::node_fn(NaturalLogParameterNode)]
fn ln(input: f32) -> f32 {
input.ln()
}

// Sine
pub struct SineParameterNode;

#[node_macro::node_fn(SineParameterNode)]
fn ln(input: f32) -> f32 {
input.sin()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The I think none of these nodes should have Parameter in their name as they don't actually take a second argument. (With AddParameter, the parameter is added to the primary input, this is not the case here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, I just copy-pasted without thinking. Should be fixed now

* Floor
* Ceil
* Round
* Absolute Value
* Logarithm
* Natural Logarithm
* sin
* cos
* tan
@isiko isiko enabled auto-merge (squash) August 14, 2023 13:39
@isiko isiko merged commit 7558088 into master Aug 14, 2023
3 checks passed
@isiko isiko deleted the more-math branch August 14, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants