> The only issue I have is that it doesn't evenly distribute the spheres
along the ellipse, maybe that's not easy to accomplish?

Got an interesting thought-experiment for you. :) What would it look like
to only distribute 3 or 4 spheres in an ellipse, with even spacing? Pen and
paper is allowed.

On Mon, 10 Oct 2022 at 11:41, johancc <joao.chave...@gmail.com> wrote:

> Hey Justin. That's awesome! Thanks a lot for looking into it. The only
> issue I have is that it doesn't evenly distribute the spheres along the
> ellipse, maybe that's not easy to accomplish?
> But this helps me a lot anyways. :)
>
>
> [image: ellipse.jpg]
> A segunda-feira, 10 de outubro de 2022 à(s) 08:38:18 UTC+1,
> justin...@gmail.com escreveu:
>
>> Full disclosure, I am not a math guy and I didn't know the solution
>> straight away. But I wanted to look it up and see if I could apply it,
>> given a known max and min radius, and an angle.
>> I found this to be the most useful of all the links I had found:
>> https://stackoverflow.com/a/17762156/496445
>>
>> What do you think of this solution I came up with based on that?
>> https://gist.github.com/justinfx/b257dc162680978786ed4fd45409c997
>>
>>
>> On Mon, Oct 10, 2022 at 9:52 AM joão chaves <joao.c...@gmail.com> wrote:
>>
>>> Hey all.
>>>
>>> I have a simple script that distributes spheres in a circular pattern
>>> (fixed by Justin Israel), and was looking for a solution that would
>>> distribute them in an ellipse/oval pattern. I am also trying to do this in
>>> bifrost, but as I have done for the circular pattern I need to understand
>>> the math first in python.
>>>
>>> I also found this formula “(x2/a2) + (y2/b2) = 1” but not sure how to
>>> apply it.
>>>
>>> Thank you!
>>>
>>> import maya.cmds as cmds
>>>
>>> degrees = 180
>>> max_iterations = 21
>>> t_x = 6
>>> radius=0.15
>>>
>>> for i in range(max_iterations):
>>>
>>>     print(i)
>>>
>>>
>>>     if degrees % 360 == 0:
>>>         rotation = float(degrees) / max_iterations * i
>>>     else:
>>>         rotation = float(degrees) * i / (max_iterations-1)
>>>
>>>     my_sphere = cmds.polySphere(r=radius)
>>>     cmds.move(t_x,my_sphere, x=1 , absolute=1)
>>>     cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot', 
>>> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>>>
>>>     cmds.rotate(rotation, my_sphere, y=1)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to python_inside_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/fbe47165-173a-477e-bbdb-1a51d275764dn%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/fbe47165-173a-477e-bbdb-1a51d275764dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB2wG%2BZ%2Bamc9ervea_Fx7%3DmTcZGxrgE44v%3DYvm44JOfMw%40mail.gmail.com.

Reply via email to