WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-28-2010, 01:42 AM
IGoudt IGoudt is offline
Member
 
Join Date: Sep 2009
Posts: 20
calculating orientation and approaching

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

Code:
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()
Reply With Quote
  #2  
Old 01-30-2010, 04:10 AM
IGoudt IGoudt is offline
Member
 
Join Date: Sep 2009
Posts: 20
I solved my problem with ray-tracing, you can leave this topic open if you want to solve it for others
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:30 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC