Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Look at func
-
😬😴 i dont know if its the lack of sleep or increased stress... but i have completely forgoten how to write a LookAt function... can anyone give me hand?
Im trying to get Object A to look at Object B
-
This might not be the best way but it seems to work..
def LookAt(pos1, pos2): dx, dy = pos1[0]-pos2[0], pos1[1]-pos2[1] angle = math.degrees(math.atan2(float(dy), float(dx))) angle += 90 if angle < 0: angle += 360 print(angle) return angle
the
+90
is so 0 is north (screen.w/2, screen.h)otherwise 0/360 is left center
-
-
@stephen said:
but theres nothing on the post
I've already posted something, then deleted, then purged but I don't know how other see it.
-
@cvp said:
@stephen said:
but theres nothing on the post
I've already posted something, then deleted, then purged but I don't know how other see it.
only post and Notification i get if for this one ⇪⇪⇪ where i still have notification from the @njm even if the post was deleted lol 😧 i just get anxious when random buts happen lol especially if i cant hunt it down myself 😶🤪😜
-
@stephen, I always keep a vector class ready. I have it in many places, at least in scripter:
from scripter import Vector import scene pos1 = scene.Point(100, 100) pos2 = (50, -20) vector1 = Vector(pos1) vector2 = Vector(pos2) delta = vector1 - vector2 # vector from pos2 to pos1 print('Degrees:', delta.degrees) print('Radians:', delta.radians) print('Distance:', delta.magnitude) # Move pos1 twice as far away from pos2 # and rotate using pos2 as origo delta *= 2 delta.degrees += 10 print('New pos1:', vector2 + delta)
-
@mikael Awesome! thank you
-
-
@njm said:
@stephen, I replied and then realized I hadn't read your post fully. I then deleted and purged it. Sorry for the confusion. I would code it the some way you did. I do like @mikael 's method, very pythonic. Many thanks to both of you for supporting this wonderful app.
Awesome thank you for clearing that up! and same to you!