Closed elanhickler closed 6 years ago
i think so. can be used with anything that has 3 coordinates.
yes, but is it the math you'd expect to see? He has several rotation functions, seem to be unique per algorithm.
Would be nice to include in your library, a general purpose rotation.
i'd like to include into my library a general 3D-to-2D mapper that can be set up in terms of a camera position, viewing direction (point to look at) and camera orientation...and possibly zoom. i'm not sure what the most convenient parametrization of something like that is. ...and i think the mapping function above can then be seen as a special case with some restrictions/constraints of the more general setup.
the math, i'd expect to see in the general case is probably a 4x4 matrix in homogenous coordinates. depending on how you set up constraints and parameters, it may then boil down to something like the code above
it could also (more directly) be expressed as a 3x3 matrix plus a vector addition of a 3-vector - but typically, in computer graphics, one adds a 4th dimension to the vectors. that way, shifts can also be expressed/included in a matrix-vector-multiply. you have probably seen a lot of that stuff in your OpenGL code
then, we could set up a differential equation system in 3D - like the lorenz system - and fly around it while it does its thing :-)
or a 3D version of my raybouncer. or a set of parametric equations, i.e. give explicit formulas for x(t), y(t), z(t) for a particle trajectory
I want to make a 3d lorenz RIGHT NOW.
btw I just came up with a 2d rotation function, not that you need the math since you already know it.
void rotate(double degreesInPhase, double inX, double inY, double * outX, double * outY)
{
double s, c;
rosic::sinCos(degreesInPhase, &s, &c);
*outX = inX * c - inY * s;
*outY = inX * s + inY * c;
}
the interesting part about 3d to 2d though, like I keep saying, is that you can convert Z into speed instead of just mixing it down to 2D like a boring person :)
But I think this can be done inside the function rather than inside a phase incrementor. You just add a curve to the final output I think, linear to something curved?
There is a z_depth parameter in the equation I posted, no idea if it's going to actually work, since I'm just pulling it out of an algorithm that may be expecting a certain input.
heehee
namespace waveshape2D
{
void rotate(double degreesOfPhase, double inX, double inY, double * outX, double * outY)
{
double s, c;
rosic::sinCos(degreesOfPhase, &s, &c);
*outX = inX * c - inY * s;
*outY = inX * s + inY * c;
}
void circle(double phase, double * outX, double * outY)
{
rosic::sinCos(phase, outX, outY);
}
void diamond(double phase, double * outX, double * outY)
{
*outX = waveshape::tri(phase);
*outY = waveshape::tri(phase+phase90degrees);
}
void square(double phase, double * outX, double * outY)
{
diamond(phase, outX, outY);
rotate(phase45degrees, *outX, *outY, outX, outY);
}
void squarepoint(double phase, double * outX, double * outY)
{
waveshape::square(phase);
waveshape::square(phase+phase90degrees);
}
}
I want to make a 3d lorenz RIGHT NOW.
rosic::LorentzSystem ...but i think, you have your own anyway
next? how about a sound generator module for chainer where you can enter the differential equations like in func shaper. i certainly want to do this someday
Your LorentzSystem had a few problems though.
ah - soo this youtube demo was my code? i did not really test it very much. seems like i tend to confuse lorenz with lorentz:
https://en.wikipedia.org/wiki/Lorentz_transformation
hmmm...yeah....maybe i should include a saturation/clipping to prevent it from exploding?
as for improving the quality without oversampling: oversampling actually lowers the stepsize for the numerical ode-solver (which, in this case, is the simple forward euler method - which is the simplest).
https://en.wikipedia.org/wiki/Numerical_methods_for_ordinary_differential_equations
maybe higher order methods such as runge-kutta could improve things
in the video, it seems like as you increase frequency, there's a threshold above which it goes into noise. at low frequencies, it's fairly periodic - you get a bam bam bam bam....but if you increase the freq, you don't get a periodic waveform
I just did some hours of testing Lorenz to prove whether I am getting an accurate sound or whether it's not accurate due to existing in the digital domain (and not being produced by an analog synth).
It's confusing because it sounds "quantizy" and digital as if locking onto aliasing harmonics. But here are some things that prove it's not because of digital domain:
https://soundcloud.com/elanhickler/oh-my-little-chaos-generator
To know if you're getting digital distortion of the chaos, just use no oversampling and sweep the frequency (looking at FFT graph helps) and if there's any aliasing harmonics, you will hear and see it locking on to those harmonics. Then turn up oversampling (and maybe retune the chaos frequency) and that behavior will disappear
I think the reason it sounds digital by nature is because it's locking and unlocking onto itself at various multiples and divisions of is harmonics. It makes sense. The less stable the chaos, the more range of locking it has, and therefore the more noisy it is. Maybe that is the fundamental nature of chaos, it's how many related frequencies it locks on to and how fast that locking changes. It can be so fast it is pure white noise or it can be so slow that you get a tone.
I have this rotation function from one of Jerobeam's algorithms:
Can this be used to rotate something like the X/Y/Z out of lorenz?: http://users.physics.harvard.edu/~horowitz/misc/lorenz.htm