I have this equation:
R= 2*(-I dot N)*N + I
Can I simply type (-I)
or something similar, or do I have to multiply I
by -1?
C++ has a unary minus operator that performs negation.
- x
This negates x
, just like 0 - x
or -1 * x
would negate x
. Note that the -
in -1 * x
is also the unary minus operator.
You mention in your comment that:
I
is a direction vector
If you're using operators on non-native types, you can't assume that they are defined. It depends whether operator overloading has been implemented on the class: if there is a Vector Vector operator-()
member function
Also, mathematically speaking, (-I dot N) == -(I dot N)
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With