Hi there. The following math is actually for a shader I'm working on. At the moment, the shader has three sine wave functions- one of period 25, one of period 20, and one of period 10, with the "period" being the interval it takes to form a full oscillation. I guess you could define those as sin(14.4x), sin(18x) and sin(36x).
The issue with that is that the sine function is a little expensive on the CPU compared to other functions. I would like to apply a transformation to one sine function, to derive the other two.
The conventional way of scaling a graph horizontally is of couse to change the value of A in sin(Ax), but in a coding context that would require me to do the sin operation three times to derive those three functions. Sounds like a minor thing, but when the operation gets applied to every single patch of water in an entire video game...
So effectively what I am looking for is a function outside of the sin operation, to derive the others like so:
FunctionA(sin(18x)) = sin(36x)
FunctionB(sin(18x)) = sin(14.4x)
Any ideas?
The issue with that is that the sine function is a little expensive on the CPU compared to other functions. I would like to apply a transformation to one sine function, to derive the other two.
The conventional way of scaling a graph horizontally is of couse to change the value of A in sin(Ax), but in a coding context that would require me to do the sin operation three times to derive those three functions. Sounds like a minor thing, but when the operation gets applied to every single patch of water in an entire video game...
So effectively what I am looking for is a function outside of the sin operation, to derive the others like so:
FunctionA(sin(18x)) = sin(36x)
FunctionB(sin(18x)) = sin(14.4x)
Any ideas?