First of all, thank you for your attention
 I will try this and see what happens

 Im just learning soya, and im amazing with what it can do!

thanks all


> On 19 d?c. 07, at 10:22, Souvarine wrote:
>
> > For your task there is an easy way to go : Just create a vector
> > oriented
> > toward north with your scene (world) as parent. Then create a vector
> > with your character as parent and oriented toward the front of your
> > character. And that's it, any time you want to check the
> > orientation of
> > your character from north you use the angle_to method with those two
> > vectors. Easy :)
>
>         But take care that this vector may not be in the horizontal plane
> (as the north vector is). Therefor, the angle_to methode will not
> return the exact angle to north. you have project this vector on the
> horizontal plane
>
> (example where the horizontal plane's equation is "y=0" (or any
> constant))
>
> # Having
> field = World()
> north = Vector(field,43,0,53) # the 0 is mandatory. The two other
> value (43, and 54) have to be set as wished)
> agent= Body(field)
>
> # You get the angle to north with :
> agent_front = Vector(agent,0,0,-1)      # you get the agent front
> agent_front %= field    # convert the agent_front vector in the field
> coordonate
> agent_front.y   # project the vector on the horizontal plane
> angle = agent_front.angle_to(north)     # calculate the angle to north
> (yeah it's the most useful comment
>
>
> #######################################
> ### But beware ! ! ! This is the angle to north, not the orientation,
> I mean than east and west will have the same value. You have to
> determine this another way.
>
>
> # but when your north vector run along the X ou Z axis you just have
> to test the value of the other axis
>
> # Having
> north = Vector(field,0,0,-1) # the north run along the Z axis
>
> #add this after angle calculation
> if agent_front.x < 0: # If the vector is at East.
>         angle = 360-angle
>
>
> It may be a good idea to make a tutorial of it. :-)
>
>
> Have fun.
>
>
> --
> marmoute
>

_______________________________________________
Soya-user mailing list
Soya-user@gna.org
https://mail.gna.org/listinfo/soya-user

Reply via email to