Hi Tristam,

Thanks for this, although it seems as though I can't get it to work
correctly.

This is the code I have so far ...

import math
import pyglet

from pyglet.gl         import *
from dotmic.pyglet  import extensions

window = extensions.Window(width=1024, height=768)

class Rotation(object):
    def __init__(self):
        self.angle = 0.0
        self.x = 0.0
        self.y = 0.0

rotation = Rotation()

def world():

    glColor3f(0.2, 0.2, 0.2)

    glPushMatrix()

    glTranslatef(window.width / 2, window.height / 2, 0.0)
    glRotatef(rotation.angle, 0.0, 0.0, 1.0)

    size = 300

    glBegin(GL_QUADS)
    glVertex2f(size, size) # Top right
    glVertex2f(-size, size) # Top left
    glVertex2f(-size, -size) # Bottom left
    glVertex2f(size, -size) # Bottom right
    glEnd()

    glPopMatrix()

    angle = math.radians(rotation.angle)
    rotation.x, rotation.y = size * math.cos(angle), size * math.sin
(angle)

    glColor3f(1.0, 1.0, 1.0)

    glBegin(GL_POINTS)
    glVertex2f(rotation.x, rotation.y)
    glEnd()

@window.event
def on_mouse_scroll(x, y, scroll_x, scroll_y):
    rotation.angle += scroll_y

@window.event
def on_draw():
    glClear(GL_COLOR_BUFFER_BIT)
    glLoadIdentity()

    world()

    fps.draw()

fps = pyglet.clock.ClockDisplay()
window.set_visible()
pyglet.app.run()

(Ignore the extensions stuff, it's just a window subclass that auto
centers the window on the screen)

What I'm trying to achieve is to have a white point attached to each
corner of the quad, that are located on the normal matrix rather than
the rotated one. I have started here with the top right corner, and as
you can see it's not quite working right. I was hoping to avoid trig
as it's not my strong point.

Any ideas ?

Thanks

-Mic

On Dec 23, 6:20 pm, "Tristam MacDonald" <[email protected]> wrote:
> On Tue, Dec 23, 2008 at 1:57 PM, Mic Pringle <[email protected]> wrote:
>
> > Hi,
>
> > Does anyone know if its possible to find out the corner point
> > locations of a quad after it's been rotated using glRotatef ?
>
> There is no functionality in the API for this, however you can calculate
> where it will be using trigonometry or (arguably simplex) matrices.
>
> Given your rotation by 5 degrees (I assume you meant about the y-axis), the
> trig solution would look like this:
>
> angle = math.radians(5.0)
>
> new_x = x * math.cos(angle)
> new_y = y * math.sin(angle)
>
> - Tristam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to