Author Topic: Turret angle to vector program please!  (Read 5094 times)

0 Members and 1 Guest are viewing this topic.

Turret angle to vector program please!
Could someone please write a simple program that you can enter the 3 axises and it'll spit out the forward and up vectors?  Or at least the formula for it.  I still can't get my brain wrapped around it  :confused:
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Turret angle to vector program please!
I'm not sure what you're talking about, but I did write a little app a long time ago for calculating the rotation matrix to use in missions if you wanted a ship oriented with a specific heading, pitch and roll (instead of using "point to" or manual rotation in fred).

Are you trying to calculate the relative vector (target is (x, y, z) units away from a point)?

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
Normal vectors can be confusing at first.  What you have to know is that a normal vector is specifying a relative point.  The three axes are the X (left-right), Y (up-down), and Z (forward-back) in that order.  So if you have a turret on the left side of a ship, facing forward, its forward vector should be 0,0,1 (a point one unit forward), and its up vector should be 1,0,0 (or maybe its -1,0,0), specifying a point one unit to the left.

 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
Re: Turret angle to vector program please!
Is it that hard to stick a few numbers into the box in PCS2 and see which way the stick points? :P
(´・ω・`)
=============================================================

 
Re: Turret angle to vector program please!
Depends on the level of control you want. :P

It's why I wrote my little app, so I can set up a bunch of RBCs or something and have them all pointing exactly where I want.

 
Re: Turret angle to vector program please!
I can do top, bottom, left right facing with no major problems, but when you start getting into odd degrees I have no idea how to compute.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
When you get into odd angles (other than 45% which is easy), then you need to use trigonometry to get it.  This can be complicated.

 
Re: Turret angle to vector program please!
What numbers/values do you actuall have? Exactly what values are you trying to calculate?

Is this what you're looking for?

http://en.wikipedia.org/wiki/Spherical_coordinates#Cartesian_coordinate_system

2 angle input, your r is always 1 for the turret normals anyway.

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
OK.  I made a diagram that shows what you need to do.  Should be doable on any scientific calculator (I would be surprised if your computer didn't have one built in).  MAKE SURE IT IS IN DEGREE MODE FIRST, otherwise it will think you are using radians.  You should be able to use this to generate a vector (just imagine the hypotenuse as the vector you want).

[attachment deleted by ninja]

 
Re: Turret angle to vector program please!
I think I had something like that but something's messed up.

I've got a turret set at 150,0,90 (truespace angle)

150 is -30 from straight down left.  (flipped vert it's 30)

sin (30) = .5
cos (30) =  .866

$uvec:-.866, -.5, 0
$fvec:0,0,1

The turret rotates in the wrong angle, and the barrel tries to ain backwards.  Ugh
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
You could try flipping -0.866 to +0.866.  It might not help, but I find I always forget which direction along the X axis is positive.  Could also be that the code is just messed up.

 

Offline Zoltan

  • 26
Re: Turret angle to vector program please!
I think I had something like that but something's messed up.

I've got a turret set at 150,0,90 (truespace angle)

150 is -30 from straight down left.  (flipped vert it's 30)

sin (30) = .5
cos (30) =  .866

$uvec:-.866, -.5, 0
$fvec:0,0,1

The turret rotates in the wrong angle, and the barrel tries to ain backwards.  Ugh


I've never done anything with vectoring, so I could be completely wrong, but shouldn't -.5 be a Z value?

try:
$uvec: 0.5, 0, -.866
$fvec: 0, 0, 1
« Last Edit: April 05, 2008, 04:52:02 am by Zoltan »
"A child of five would understand this. Send someone to fetch a child of five." - Groucho Marx

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Turret angle to vector program please!
Just a suggestion if you are not into trigonometry... Take the model you have and open it in truespace. Use the TS 'sweep' thing IIRC (havent got TS installed here ATM) on the surface where you planning to place the turret on after checking that sweep has been set to 0,0,1. Then choose one of the vertexes on the new poly and copy its stats somewhere (coordinates). Then choose the corresponding vertex on the old poly and do the same. Do subtraction. Got nice set of coordinates. Only problem is figuring out which one points where when the model is converted.

If you are into trigonometry then solving these shouldn't be that difficult without any fooling with the models.

EDIT.. should be worth noting that XYZ in TS are not the same as in FS. By very brief look now that i installed it again.. TS XYZ -> FS ZXY if i am not mistaken
« Last Edit: April 05, 2008, 04:53:30 am by Wanderer »
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Vasudan Admiral

  • Member
  • 211
    • Twisted Infinities
Re: Turret angle to vector program please!
If you want to visualise it, fvecs and uvecs are like two gunpoints pointing out the front and top of your turret respectively.

Just make a tempoary gunpoint, switch to wireframe and drag it into the centre of the base of your turret. Go to front or side or wherever orthogonal views of your model and enter numbers in the normal for that point. Use largeish numbers so you turn the firepoint into an axis line. Fiddle with the numbers until you get an axis line that is as accurate as you want it, then 'Normalise' the point so it uses nice small numbers again. This becomes your uvec.

The fvec I suspect may have a bug in it where it actually needs to point backwards. Just point it along the same direction the turret is facing and find out if the arms rotate correctly. If not, try reversing it.

It's all very easy though. You really don't need this stuff to be pinpoint precise. ;)
Get the 2014 Media VPs and report any bugs you find in them to the FSU Mantis so that we may squish them. || Blender to POF model conversion guide
Twisted Infinities

 
Re: Turret angle to vector program please!
Ok this is strange,

I moved the turret back to 0,0,0 and rotated it back up normal.  I added two small boxes, one add (0,0,0) and one at (0,0,1).  I then rotated it back to 150, the second box does show (0,.5,-.866). So that parts correct.

Now if I go into pcs2 and use (.5, 0, .866) in any positive/negative combination it doesn't make any difference, the turret is still rotating the wrong way.  :confused:
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
Just had a thought.  It seems weird, because I would have though that someone would think of it already, but it might work.  Try:

$uvec=-0.5,-0.866,0

I think you have the X and Y axis flipped (its complicated).  Just try it.

EDIT: I had if flipped too.
« Last Edit: April 05, 2008, 10:13:25 pm by blowfish »

 

Offline Zoltan

  • 26
Re: Turret angle to vector program please!
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.

This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.
"A child of five would understand this. Send someone to fetch a child of five." - Groucho Marx

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.

This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.

That's what I was thinking in my last post.  Flipping the X and Y are definitely worth a try (since 60 and 30 are essentially opposites in a right triangle).

 
Re: Turret angle to vector program please!
Correct it would be 60 degrees from top in the second quad and 30 degrees from the bottom in the second quad.  But using the two squares method is easier, no calcuations need to be done  :)
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 
Re: Turret angle to vector program please!
I have said before that I am ignorant, when it comes to vectors, and I'll say that again.

This might help people who know more:
150 is not (or should not be) 30 degrees, it should be 60 and should be in the second quadrant instead of the third. Hope that helps with your calculations.

That's what I was thinking in my last post.  Flipping the X and Y are definitely worth a try (since 60 and 30 are essentially opposites in a right triangle).

I think I'm correct assuming I have a point A one unit above the origin(0,0,1), I then rotate it delta degrees (150), point A will be .5 unit to the left and .866 units down from the origin.  These two numbers would be the unit vector, since A should still be one unit away from the origin.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"