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

0 Members and 2 Guests are viewing this topic.

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.

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).

That's been bugging me. Could someone explain to me how you could get a Y value other than 0 or 1, using sine and cosine for something with the coordinates 150, 0, 90?
"A child of five would understand this. Send someone to fetch a child of five." - Groucho Marx

 
Re: Turret angle to vector program please!
I tried something, I made a eye point and made it's normal (.5, -.866,0) and its pointing in the correct direction..
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!
So try that on the turret.  If it works, the problem solved.  If not, either there's something glaring obvious that we're all missing, or there's an error in the code.

 
Re: Turret angle to vector program please!
So try that on the turret.  If it works, the problem solved.  If not, either there's something glaring obvious that we're all missing, or there's an error in the code.

Already tried that, didn't help.  Even negated the numbers. 
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 Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Turret angle to vector program please!
did they fix multi axis turrets?

oh yea, an excerpts from my matrix class:

   mat(double x, double y, double z) //convert eulers to matrix
   {
      double a,b,c,d,e,f,g,h;      //stick our pre-comps into an array //this comment doesn't make any sense!
      a = cos(x); b = sin(x);
      c = cos(y); d = sin(y);
      e = cos(z); f = sin(z);
      g = a * d; h = b * d;
      
      c0 = c * e; c1 = -c * f; c2 = d;
      c3 = h * e + a * f; c4 = -h * f + a * e; c5 = -b *c;
      c6 = -g * e + b * f; c7 = g * f + b * e; c8 = a * c;
   }

and

   vec operator * (vec &v)      //apply to vector
   {
      return vec(c0 * v.x + c1 * v.y + c2 * v.z,
               c3 * v.x + c4 * v.y + c5 * v.z,
               c6 * v.x + c7 * v.y + c8 * v.z);
   }

give the first function your angles of rotation , i think its in pitch, yaw, roll order. do the math and this will create a 3*3 matrix that represents the full orientation of the object. come up with a vector pointed to 0'0'1 (i think), and do the math in the second function on it (along with the components of the 0'0'1 vector, so v.x and v.y = 0 and v.z = 1). your rotated vector's x'y'z will be the first line, the second and the third respectively. theres other math to gen the side and up vectors, but i dont know it.
« Last Edit: April 05, 2008, 10:59:20 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: Turret angle to vector program please!
Ok does mat (x,y,z) produce the up vector in matrix format?
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 Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Turret angle to vector program please!
yea. you need a matrix to do the vector transform.

the matrix has 9 fields c0-c8, it stores an orientation, but you have to multiply it by a vector. the resulting vector would be of the same magnitude but rotated by the angles you created the matrix from. just remember that it rotates around 0'0'0, so a translate,rotate,untranslate may be necessary if your center isn't zero. another thing is that all input angles are in radians so be sure the calculator is set to the radians mode.
« Last Edit: April 06, 2008, 12:32:08 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Backslash

  • 29
  • Bring Our Might To Bear
Re: Turret angle to vector program please!
did they fix multi axis turrets?
Yes.  Problem is nobody knows how to use them yet :p

 

Offline Water

  • 210
Re: Turret angle to vector program please!
Make sure you try both PCS2 AND PCS1

 

Offline Equinox

  • 21
Re: Turret angle to vector program please!
I'm gonna interject here with a couple of questions.  This is a 2 part turret? If so, is the beam firing from the wrong place? if not, is the turret arm lifting away from the turret body? 

... in other words, could you post a screenshot of what's happening?

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
I'm gonna interject here with a couple of questions.  This is a 2 part turret? If so, is the beam firing from the wrong place? if not, is the turret arm lifting away from the turret body? 

From what I can tell, it is a multipart turret.  Where did you get that beam thing from though?  The problem seems to be that the turret is rotating around the wrong axis.

EDIT: Oh, and...

:welcomegreen:

 

Offline Equinox

  • 21
Re: Turret angle to vector program please!
Thanks :)

And the beam thing I ask because when I was learning multipart turrets I was having a barrel rotate out of the base of the turret... turned out I'd set the axes of the barrel wrong, so the barrel was rotating around the center instead of at one end.  Kind of sounded like maybe the same thing was happening here.

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: Turret angle to vector program please!
Thanks :)

And the beam thing I ask because when I was learning multipart turrets I was having a barrel rotate out of the base of the turret... turned out I'd set the axes of the barrel wrong, so the barrel was rotating around the center instead of at one end.  Kind of sounded like maybe the same thing was happening here.

I've had that problem too, but that's not what's going on here.  What is happening here is that Scooby_Doo is trying to use a new feature which allows multipart turrets to be placed not just on the top and bottom of the ship, but also on the sided and at weird angles on the hull.  When you do this, however, you have to specify the axis along which it rotates, and this can be *difficult* to calculate sometimes.

 

Offline Equinox

  • 21
Re: Turret angle to vector program please!
ohhhhh my mistake.  But, where's this feature documented? I wanna play with it!