[Tutor] direction and draw

János Juhász janos.juhasz at VELUX.com
Mon Jan 22 23:20:25 CET 2007


Dear Linda,

> I have a segment (two ending points are A and B) which is 0 degree.
> How to draw a segment with 10 degrees and 15 in length?
It is very simple with complex numbers:

import math

class vect:
    ## begin and end are tuples (x, y)
    ## and represented as complex numbers
    def __init__(self, begin, end):
        self.begin = complex(begin[0], begin[1])
        self.end = complex(end[0], end[1])

    def Rotate(self, deg=0):
        rad = math.radians(deg)
        rot = complex(math.cos(rad), math.sin(rad))
        self.end = self.begin + (self.end-self.begin)*rot

    def SetLength(self, length):
        dist = self.end - self.begin
        actlength = math.sqrt(dist.real**2 + dist.imag**2)
        dist = dist * length / actlength
        self.end = self.begin + dist

    def __str__(self):
        return '(%.2f, %.2f)->(%.2f, %.2f)' % \
               (self.begin.real, self.begin.imag, self.end.real, 
self.end.imag)


v = vect((10,0),(20,0))
print 'orig:', v
v.Rotate(10)
print 'rotated:', v
v.SetLength(15)
print 'sretched:', v



It seems to be a kind of homework, 
but I wanted to test how can I response in a thread.

All of my earlier responses started new threads in this list like this 
http://mail.python.org/pipermail/tutor/2007-January/052169.html.

Have I remove the '[Tutor]' or '[Tutor] ' from the subject of the response 
? 
Do I need any special about the mail in notes ?


[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Karl 
Wittgenstein 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Geoframer 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Geoframer 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Geoframer 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Danny Yoo 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Karl 
Wittgenstein 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Karl 
Wittgenstein 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Kent Johnson 
[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress   Karl 
Wittgenstein 


I don't understand how these threads are built up. The subject fields 
seems to be identicals.
Is there used anything else than the subject field for recognize the base 
of the response ?

RTFM about how to respond to this list is welcomed with valuable links.


Regards:
___________
Janos Juhasz


More information about the Tutor mailing list