[Python Wpg] Cannot figure out this ZeroDivisionError exception
Stuart Williams
stuart at swilliams.ca
Fri Mar 11 14:58:20 EST 2011
I briefly looked through your code, and the print of scale + movex makes me
wonder if you're assuming different operator precedence than Python gives
you:
nx = (x[n]+xrotoffset+camx)/nz/scale+movex
is interpreted as (formatted to match PEP8):
nx = (((x[n] + xrotoffset + camx) / nz) / scale) + movex
I suspect scale is zero, even if scale+movex is not.
camz starts at zero, and if line 68 execute then scale becomes zero.
The other thing I noticed is your code has the loop over 8 values later in
the loop than the code that you're following.
Perhaps that will help.
Stuart.
On Thu, Mar 10, 2011 at 4:33 PM, Kevin Veroneau <kveroneau at gmail.com> wrote:
> Hello,
>
> I am in the process of learning the basics of 3D math and programming,
> and thought using Python and Pygame would be a good choice to prototype in.
> The 2D example works great, the isometric 3D example also works. But in the
> 3rd example, when I press Space to enter into full 3D, it uses a flow
> control statement to change a calculation. Even though the calculation is
> very similar in both isometric and full 3D, it just does not work and I am
> very confused why.
>
> You can view the source code online in my public Subversion Repository:
> http://django.kveroneau.info/svn/node1/python/pygame/3danim2.py/cat
>
> I am following the tutorial step-by-step on this website:
> http://skytopia.com/project/cube/cube.html
>
> That website explains 3D using pseudo-code, the author made it resemble
> BASIC-like syntax for clarity. As I read through the tutorial, I coded it
> in Python, and thus is why there is three python files, one for each phase
> of the example.
>
> I thought I would ask here, as I noticed many of you on this mailing list
> using Python for mathematical purposes, and this exception is related to a
> math operation in a calculation. This is my first time going in depth with
> 3D programming and how the math behind it works. I would of course move to
> OpenGL once I understand the fundamentals.
>
> On the topic of OpenGL, which OpenGL Python library would you recommend
> someone who is just diving into GL. I feel my Python skills are pretty
> strong at this point. I understand that Blender can be scripted using
> Python, would this be a good place to start or should I use a stand-alone
> python module?
>
> Thanks,
> Kevin Veroneau
>
>
> _______________________________________________
> Winnipeg Python Users Group mailing list
> http://WinniPUG.ca
> Winnipeg at python.org
> http://mail.python.org/mailman/listinfo/winnipeg
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/winnipeg/attachments/20110311/375a8b6b/attachment.html>
More information about the Winnipeg
mailing list