Point above an object

Post » Fri Nov 16, 2012 3:43 pm

Ugh... 3D math question:

I have an object (the fishing Pole) which, when the rotation is 0x 0y 0z lies flat on the ground, pointing north. I would like it to point, like a compass, to an arbitrary object's location. As long as it's flat, easy - rotate Z.

The trouble is that I want it to point at a 45 degree angle somewhere above the other object... just like you'd stick a fishing pole in the ground, pointing toward a school of fish. But when I rotate the XY angles, it spins off into wild positions. Rotations in 3D space is a [censored], lol.

I plotted the desired end points for north, south east and west:

315x 000y 000z n
000x 045y 090z e
045x 000y 180z s
000x 315y 270z w

I know enough to recognize this is a sine/cos/tan equation, but my math experience was limited to Math 001 "Math Without Fear" so this is a little beyond me.

;; get heading angle. This works just finefloat zOffset = deployedPole.GetHeadingAngle( closestCritterFish )float angleZ = deployedPole.GetAngleZ() + zOffset;; After we rotate to z-point at fish, tilt pole 45deg... but this obviously doesnt work:float angleX = Math.Sin(45)float angleY = Math.Cos(45)deployedPole.SetAngle( angleX, angleY, angleZ )
Question: Knowing my rotation angle Z, how do I solve for XY so that the object in question is always 45-degrees to the ground?
User avatar
Alexandra Ryan
 
Posts: 3438
Joined: Mon Jul 31, 2006 9:01 am

Post » Fri Nov 16, 2012 12:00 pm

Much trial and error:

float zOffset = deployedPole.GetHeadingAngle( closestCritterFish )
float angleZ = deployedPole.GetAngleZ() + zOffset
float angleX = -45*Math.Cos(angleZ )
float angleY = 45*Math.Sin(angleZ )
deployedPole.SetAngle( angleX, angleY, angleZ )
User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Post » Fri Nov 16, 2012 12:56 pm

wow, wish you were around when I was trying to do a similar thing with my Oblivion double arrow knocked mod. The 2nd arrow was controlled by the first and I had similar issues with some angles. I loved trig in school but I was never great at it, er... plus "school" for me was like 30 years ago...


Much trial and error:

float zOffset = deployedPole.GetHeadingAngle( closestCritterFish )
float angleZ = deployedPole.GetAngleZ() + zOffset
float angleX = -45*Math.Cos(angleZ )
float angleY = 45*Math.Sin(angleZ )
deployedPole.SetAngle( angleX, angleY, angleZ )
User avatar
Rob Smith
 
Posts: 3424
Joined: Wed Oct 03, 2007 5:30 pm

Post » Fri Nov 16, 2012 7:06 am

plus "school" for me was like 30 years ago...

Yeah I remember moon landings, too =)
User avatar
Franko AlVarado
 
Posts: 3473
Joined: Sun Nov 18, 2007 7:49 pm

Post » Fri Nov 16, 2012 7:09 am

Sounds like the mesh origin is off center.

You could unpack the mesh from the bsa file and alter its origin with Nifscope. Then duplicate the fishing pole in the CK and point the duplicate to the altered mesh.
User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am

Post » Fri Nov 16, 2012 8:37 pm

Actually the mesh is fine, the fix was more of a trig equation than anything, since rotating anything using XYZ coords rather than a mouse is confusing. I got it working though.

However I wasnt aware nifscope could alter origins, and now you have me wondering if i can use it to attach the pole to the players hand.... hmmm....
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Fri Nov 16, 2012 4:46 am

Oooh, a fishing mod. I'll be keeping an eye out for that one Arodicus

- Hypno
User avatar
Javier Borjas
 
Posts: 3392
Joined: Tue Nov 13, 2007 6:34 pm


Return to V - Skyrim