IGoudt
01-28-2010, 01:42 AM
Hello,
I am working on a collision avoidance project with avatars. I am trying to find out the angle 2 avatars are walking at to eachother.
What I do is:
- I take the Euler orientation of the avatar (x-part)
- I calculate the angle between avatar#1 and avatar#2 with vizmat.angleToPoint
- 100% sure that both the Euler and angleToPoint are North oriented, I subtract them. If the result lies close to 0 then I should know that avatar#1 is walking to avatar#2.
I am simulating this in the code you can read here. The problem is though that the values are correct when the objects/avatars are far away from each other, but they produce, IMO, wrong results when they are getting closer.
If someone could help me achieve or give me a push into the correct direction, I would be grateful :)
import viz
import vizact
import types
import math
import random
import vizmat
viz.go()
class angleTest:
def __init__(self):
ground = viz.add('tut_ground.wrl')
self.male_1 = viz.addAvatar('male.cfg')
self.male_1.setPosition(0, 0, 10)
self.male_1.setEuler(90,0,0)
self.female_1 = viz.addAvatar('female.cfg')
self.female_1.setPosition(10, 0, 10)
vizact.ontimer(0.1, self.checkDistance)
def checkDistance(self):
#print self.male_1.getAction().data
male_pos = self.male_1.getPosition()
female_pos = self.female_1.getPosition()
print vizmat.Distance(male_pos,female_pos)
angle = vizmat.AngleToPoint(male_pos[0], male_pos[2], female_pos[0], female_pos[2])
print "male position: " + str(male_pos)
print "female position: " + str(female_pos)
print "angle: " +str(angle)
print "orientation: " +str(self.male_1.getEuler()[0])
print angle - self.male_1.getEuler()[0]
print "*****"
def move(self):
self.male_goal = [10,0,10]
male_walkaction = vizact.walkTo(self.male_goal,1)
self.male_1.addAction(male_walkaction)
self.female_goal = [0,0,10]
female_walkaction = vizact.walkTo(self.female_goal,1)
self.female_1.addAction(female_walkaction)
s = angleTest()
s.move()
I am working on a collision avoidance project with avatars. I am trying to find out the angle 2 avatars are walking at to eachother.
What I do is:
- I take the Euler orientation of the avatar (x-part)
- I calculate the angle between avatar#1 and avatar#2 with vizmat.angleToPoint
- 100% sure that both the Euler and angleToPoint are North oriented, I subtract them. If the result lies close to 0 then I should know that avatar#1 is walking to avatar#2.
I am simulating this in the code you can read here. The problem is though that the values are correct when the objects/avatars are far away from each other, but they produce, IMO, wrong results when they are getting closer.
If someone could help me achieve or give me a push into the correct direction, I would be grateful :)
import viz
import vizact
import types
import math
import random
import vizmat
viz.go()
class angleTest:
def __init__(self):
ground = viz.add('tut_ground.wrl')
self.male_1 = viz.addAvatar('male.cfg')
self.male_1.setPosition(0, 0, 10)
self.male_1.setEuler(90,0,0)
self.female_1 = viz.addAvatar('female.cfg')
self.female_1.setPosition(10, 0, 10)
vizact.ontimer(0.1, self.checkDistance)
def checkDistance(self):
#print self.male_1.getAction().data
male_pos = self.male_1.getPosition()
female_pos = self.female_1.getPosition()
print vizmat.Distance(male_pos,female_pos)
angle = vizmat.AngleToPoint(male_pos[0], male_pos[2], female_pos[0], female_pos[2])
print "male position: " + str(male_pos)
print "female position: " + str(female_pos)
print "angle: " +str(angle)
print "orientation: " +str(self.male_1.getEuler()[0])
print angle - self.male_1.getEuler()[0]
print "*****"
def move(self):
self.male_goal = [10,0,10]
male_walkaction = vizact.walkTo(self.male_goal,1)
self.male_1.addAction(male_walkaction)
self.female_goal = [0,0,10]
female_walkaction = vizact.walkTo(self.female_goal,1)
self.female_1.addAction(female_walkaction)
s = angleTest()
s.move()