Forged Alliance Forever Forged Alliance Forever Forums 2015-01-23T16:33:20+02:00 /feed.php?f=2&t=9288 2015-01-23T16:32:48+02:00 2015-01-23T16:32:48+02:00 /viewtopic.php?t=9288&p=91997#p91997 <![CDATA[Re: Need help converting rotation vectors]]>
Vee wrote:
If the projectile impact is represented as a vector (which makes more sense to me than representing it as euler angles, but who knows), then the library function you need is not quaternion to euler angles, it's rotating a vector by a quaternion.


Does this library function exist or do i need to create it ?

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 16:32


]]>
2015-01-23T16:33:20+02:00 2015-01-23T16:30:28+02:00 /viewtopic.php?t=9288&p=91996#p91996 <![CDATA[Re: Need help converting rotation vectors]]>
IceDreamer wrote:
For splash, why not filter projectiles which have it, and if there was no direct impact checking oncollide then use impact position, self position, and orientation to figure out where you were hit might work. Pretty intensive though.


Well, that's just it, there 's nothing within the game setup to tell a unit that the damage it's taking is direct or splash. Currently you have to do something similar to what you are suggesting above and work everything out before the damage is dealt. IMO it would be better to revamp the damageType's to provide for more detail in just what type of damage is being applied.

Note: This is part of why WOF was such a nightmare... Very little if any of the information required is passed from the launcher to the projectile and later to the impacted unit. This makes it very hard to identify who shot who, when and from what position. While some might think this is a trivial matter, it's not as not all projectiles / damage behaves the same.

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 16:30


]]>
2015-01-23T16:24:54+02:00 2015-01-23T16:24:54+02:00 /viewtopic.php?t=9288&p=91994#p91994 <![CDATA[Re: Need help converting rotation vectors]]> Statistics: Posted by IceDreamer — 23 Jan 2015, 16:24


]]>
2015-01-23T16:21:10+02:00 2015-01-23T16:21:10+02:00 /viewtopic.php?t=9288&p=91993#p91993 <![CDATA[Re: Need help converting rotation vectors]]>
If the projectile impact is represented as a vector (which makes more sense to me than representing it as euler angles, but who knows), then the library function you need is not quaternion to euler angles, it's rotating a vector by a quaternion.

Statistics: Posted by Vee — 23 Jan 2015, 16:21


]]>
2015-01-23T16:01:00+02:00 2015-01-23T16:01:00+02:00 /viewtopic.php?t=9288&p=91991#p91991 <![CDATA[Re: Need help converting rotation vectors]]>
Vee wrote:
Ah, quaternions. I was confused by the d in quad. In that case it's probably simplest to rotate the impact vector by the inverse of the orientation quaternion. It's highly likely that there is a library function for that in the game already, since that's the whole point of quaternions. Then you can look at the x,y coordinates of the resulting vector to determine from which direction it's coming.


Well the issue isn't the projectiles vector / direction but was the units. (projectile given in Euler while unit was in Quaterions) I guess I could turn the projectiles vectors into Quad to see if the X & Y is usable for what I'm attempting to do.

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 16:01


]]>
2015-01-23T15:57:38+02:00 2015-01-23T15:57:38+02:00 /viewtopic.php?t=9288&p=91989#p91989 <![CDATA[Re: Need help converting rotation vectors]]>
Vee wrote:
Is there a list of lua library functions provided by the game?


Yes but Quad to Euler conversions isn't one of them...
May be worth adding it in case someone can use this later on.

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 15:57


]]>
2015-01-23T15:51:21+02:00 2015-01-23T15:51:21+02:00 /viewtopic.php?t=9288&p=91987#p91987 <![CDATA[Re: Need help converting rotation vectors]]>
Vee wrote:
BTW, based only on the orientation and damage and the impact vector you can't actually determine 100% which side was hit. It could well be that the projectile came pretty much from the front direction, but it hit the side of the unit.


Yeah splash damage is always going to be an issue with this, regardless of where it came from...

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 15:51


]]>
2015-01-23T14:38:08+02:00 2015-01-23T14:38:08+02:00 /viewtopic.php?t=9288&p=91977#p91977 <![CDATA[Re: Need help converting rotation vectors]]>
I don't think converting to euler angles is going to help you, since at the end you still want to rotate the impact vector, which is actually easier with quaternions.

Is there a list of lua library functions provided by the game?

BTW, based only on the orientation and damage and the impact vector you can't actually determine 100% which side was hit. It could well be that the projectile came pretty much from the front direction, but it hit the side of the unit.

Statistics: Posted by Vee — 23 Jan 2015, 14:38


]]>
2015-01-23T14:31:42+02:00 2015-01-23T14:31:42+02:00 /viewtopic.php?t=9288&p=91976#p91976 <![CDATA[Re: Need help converting rotation vectors]]>
Front impact, dmg reduction.
Side impact, normal dmg.
Rear impact, dmg increase.

ect...

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 14:31


]]>
2015-01-23T14:29:13+02:00 2015-01-23T14:29:13+02:00 /viewtopic.php?t=9288&p=91975#p91975 <![CDATA[Re: Need help converting rotation vectors]]>
Vee wrote:
BTW, what do you mean by quad vector? Is that a vector in homogeneous coordinates?


Quaternion old chap!

x,y,z,w = quad or four

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 14:29


]]>
2015-01-23T14:27:05+02:00 2015-01-23T14:27:05+02:00 /viewtopic.php?t=9288&p=91974#p91974 <![CDATA[Re: Need help converting rotation vectors]]>
Looks like i will be basing the rest of my work off of the UEF engineers until i have a working script i can test with hover units.

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 14:27


]]>
2015-01-23T14:22:34+02:00 2015-01-23T14:22:34+02:00 /viewtopic.php?t=9288&p=91973#p91973 <![CDATA[Re: Need help converting rotation vectors]]>
Code:
v*w = |v| |w| cos a


Where |v|, |w| are the length of the vectors, and a is the angle, and v*w is the inner product (vx*wx + vy*wy +vz*wz). If your vectors are direction vectors they have length 1, so then it's simply v*w = cos a. If that is 0 then v and w are perpendicular, if it's positive then they are pointing in a similar direction, and if it's negative they are pointing in an opposite direction.

BTW, what do you mean by quad vector? Is that a vector in homogeneous coordinates?

Statistics: Posted by Vee — 23 Jan 2015, 14:22


]]>
2015-01-23T14:20:07+02:00 2015-01-23T14:20:07+02:00 /viewtopic.php?t=9288&p=91972#p91972 <![CDATA[Re: Need help converting rotation vectors]]>
Spoiler: show
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45103454589844,
INFO: -0.055665969848633,
INFO: 0.27105712890625
INFO: }
INFO: quat to euler: \000-0.00035091885365546\0000.031428750604391\0000.019819026812911
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45115661621094,
INFO: -0.042640686035156,
INFO: 0.26837158203125
INFO: }
INFO: quat to euler: \000-0.00061906321207061\0000.034089740365744\0000.027962151914835
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45132446289063,
INFO: -0.041934967041016,
INFO: 0.194580078125
INFO: }
INFO: quat to euler: \000-0.00063757202588022\0000.047590512782335\0000.028991591185331
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45062255859375,
INFO: -0.037351608276367,
INFO: 0.19329833984375
INFO: }
INFO: quat to euler: \0000.00017512885096949\0000.048699889332056\0000.012716017663479
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45040893554688,
INFO: -0.067955017089844,
INFO: 0.106201171875
INFO: }
INFO: quat to euler: \0000.00049650622531772\0000.034507818520069\0000.0058859814889729
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45169067382813,
INFO: -0.080066680908203,
INFO: -0.044891357421875
INFO: }
INFO: quat to euler: \0001.8253631424159e-005\0000.030404286459088\0000.021862957626581
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45437622070313,
INFO: -0.14375495910645,
INFO: -0.06109619140625
INFO: }
INFO: quat to euler: \000-0.0002092887298204\0000.044387925416231\0000.02873201481998
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45120239257813,
INFO: -0.047054290771484,
INFO: -0.25149536132813
INFO: }
INFO: quat to euler: \0005.4799951612949e-005\0000.035529766231775\0000.022493848577142
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.450927734375,
INFO: -0.071207046508789,
INFO: -0.2886962890625
INFO: }
INFO: quat to euler: \0000.00029197707772255\0000.023598846048117\0000.012560334987938
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45088195800781,
INFO: -0.063501358032227,
INFO: -0.29876708984375
INFO: }
INFO: quat to euler: \0000.00016640903777443\0000.041170116513968\0000.015513479709625
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45259094238281,
INFO: -0.063764572143555,
INFO: -0.29989624023438
INFO: }
INFO: quat to euler: \000-0.00076583976624534\0000.050464242696762\0000.034828823059797
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.4527587890625,
INFO: -0.063791275024414,
INFO: -0.30001831054688
INFO: }
INFO: quat to euler: \000-0.00074305635644123\0000.041224215179682\0000.033959068357944
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45089721679688,
INFO: -0.063503265380859,
INFO: -0.29879760742188
INFO: }
INFO: quat to euler: \000-5.0702947191894e-006\0000.026482362300158\0000.010820140130818
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.44996643066406,
INFO: -0.063360214233398,
INFO: -0.29815673828125
INFO: }
INFO: quat to euler: \0000.0002496785891708\0000.030508734285831\0000.0011575418757275
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45124816894531,
INFO: -0.063556671142578,
INFO: -0.29901123046875
INFO: }
INFO: quat to euler: \000-0.0004417872405611\0000.0404985062778\0000.019916355609894
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.4530029296875,
INFO: -0.063827514648438,
INFO: -0.3001708984375
INFO: }
INFO: quat to euler: \000-0.0011352526489645\0000.034660559147596\0000.037413485348225
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45234680175781,
INFO: -0.063724517822266,
INFO: -0.29974365234375
INFO: }
INFO: quat to euler: \000-0.00081377703463659\0000.031360380351543\0000.027428731322289
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45072937011719,
INFO: -0.0634765625,
INFO: -0.29867553710938
INFO: }
INFO: quat to euler: \000-0.0002150805958081\0000.035355776548386\0000.0092899054288864
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45115661621094,
INFO: -0.063543319702148,
INFO: -0.2989501953125
INFO: }
INFO: quat to euler: \000-0.00045102796866558\0000.029411427676678\0000.016609160229564
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45220947265625,
INFO: -0.063705444335938,
INFO: -0.29965209960938
INFO: }
INFO: quat to euler: \000-0.00083460239693522\0000.037723042070866\0000.028960956260562
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.451904296875,
INFO: -0.063655853271484,
INFO: -0.2994384765625
INFO: }
INFO: quat to euler: \000-0.00055513269035146\0000.051534995436668\0000.023467356339097
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45072937011719,
INFO: -0.0634765625,
INFO: -0.29867553710938
INFO: }
INFO: quat to euler: \0006.5726992033888e-005\0000.038912989199162\0000.01055018696934
INFO: ***********************
INFO: dmg vector: \000{ <metatable=table: 14EF9028>
INFO: 0.45088195800781,
INFO: -0.063501358032227,
INFO: -0.29876708984375
INFO: }
INFO: quat to euler: \000-2.3692831746303e-005\0000.021091366186738\0000.013953930698335


Keep in mind that i am comparing the projectiles impact vectors (dmg vector) with the units current orientation vectors (quat to eular).

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 14:20


]]>
2015-01-23T14:13:16+02:00 2015-01-23T14:13:16+02:00 /viewtopic.php?t=9288&p=91971#p91971 <![CDATA[Re: Need help converting rotation vectors]]>
Code:
   QuatToEuler = function( self, quat )      
      local x, y, z, w = unpack( quat )   
      local sqx = x * x
      local sqy = y * y
      local sqz = z * z
      local sqw = w * w
      local euler = {}            
      euler[1] = math.asin(-2.0 * ( x * z - w * y ) )
      euler[2] = math.atan2( 2.0 * ( y * z + w * x ), ( sqw - sqx - sqy + sqz ) )
      euler[3] = math.atan2( 2.0 * ( x * y + w * z ), ( sqw + sqx - sqy - sqz ) )
      return euler
   end,


Now to figure out a way to use it best.

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 14:13


]]>
2015-01-23T13:44:30+02:00 2015-01-23T13:44:30+02:00 /viewtopic.php?t=9288&p=91969#p91969 <![CDATA[Re: Need help converting vectors from one type to another]]> https://github.com/grrrwaaa/gct753/blob ... s/quat.lua

Resin

Statistics: Posted by Resin_Smoker — 23 Jan 2015, 13:44


]]>