Rotate 2D Gaussian given parameters - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Rotate 2D Gaussian given parameters (/thread-31436.html) |
Rotate 2D Gaussian given parameters - schniefen - Dec-10-2020 I have a Gaussian function of the form: def f(x,y): a=some number b=... c=... return 3*np.exp(-a*(-0.5 + x)**2+b*(x-0.5)*(y-0.5)-c*(-0.5 + y)**2)This is a Gaussian function symmetric around y=x, and I'd like to rotate it 45 degrees (counter)clockwise. Wikipedia gives an overdetermined system of equations for the variances of x and y respectively, but it looks cumbersome. Is there a simple way to do this? Gaussian parameters RE: Rotate 2D Gaussian given parameters - ndc85430 - Dec-10-2020 Can't you make use of a rotation matrix? For each point (x, y) the rotation matrix would give you new points (x', y') and then you simply compute f at those new points. RE: Rotate 2D Gaussian given parameters - schniefen - Dec-10-2020 (Dec-10-2020, 06:37 PM)ndc85430 Wrote: Can't you make use of a rotation matrix? For each point (x, y) the rotation matrix would give you new points (x', y') and then you simply compute f at those new points. True. So then one would probably first need to normalize f. How would one then generate the points (x,y) using f as a density? RE: Rotate 2D Gaussian given parameters - schniefen - Dec-10-2020 (Dec-10-2020, 06:44 PM)schniefen Wrote:(Dec-10-2020, 06:37 PM)ndc85430 Wrote: Can't you make use of a rotation matrix? For each point (x, y) the rotation matrix would give you new points (x', y') and then you simply compute f at those new points. I would like to find the new parameters a,b and c of the rotated version as well. RE: Rotate 2D Gaussian given parameters - schniefen - Dec-11-2020 A rotation by 45 degrees, with the means (0.5,0.5) fixed, gives a’=(a-b+c)/2, b’=a-c=0 and c’=(a+b+c)/2 for a counterclockwise rotation and a’=(a+b+c)/2, b’=a-c=0 and c’=(a-b+c)/2 for a clockwise rotation. |