123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|698|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Translating rotation to vector components?

Fri, 05 Oct 2012, 22:30
Mog
Hi all,

Playing around with Bullet physics some more, but I'm stumped on something (mostly from not having to use this sort of math in so long!). I'm trying to convert the orientation of an object to a normal so i can Raycast in that direction, but so far it's not going so well.

The function calls for three parameters, described as "nx, ny, nz - components of a vector for a direction." but I can't remember how to resolve this... Any tips?

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Sat, 06 Oct 2012, 02:13
shroom_monk
(not going to pretend I have a lot of experience in this area, but) How is the orientation specified? As angles or also as a vector?

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Sat, 06 Oct 2012, 02:23
Mog
Angles
Sat, 06 Oct 2012, 02:53
Jayenkai
I have half a theory in my head, but I can't seem to finalise it. God I hope that's not something the brain surgery's done, I used to be good at this stuff!
If my idea formulates, I'll let you know, but it's basically a case of stripping it into two, and working it out twice with sin/cos. maybe I'm just not awake yet?

-=-=-
''Load, Next List!''
Mon, 15 Oct 2012, 14:07
emaurina
@Mog,

1. Translate the angle into a vector. (See code below)
2. Are you sure you want the normal? It sounds more like you want the vector itself. But if so, see code below.

The following code converts an angle to a normalized vector (length 1). It pops out a vector in screen space (not cartessian). Screen space is X increasing left to right and Y increasing Top to Bottom. i.e. <0,0> is in the upper left. If you need cartessian coordiantes, get change the last line to return x,y.

Note: This code is written in LUA and for the Corona SDK.



If you really need the normal, of the above vector, there are two normals for every vector:
  • <-x,y>
  • <x,-y>


One more thing. The above code is meant to handle rotations like this:


I hope this helps.