cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 05 Jun 2017 07:12 PM |
I've written 3 differentiable parametric equations that each map to a component of a positional vector in 3D space: x(theta), y(theta), and z(theta). I also have their derivatives. Normally to get the angle about a slope you can take the arctangent of the rate of change and so in 2D (assuming we care just about axes x and y) I'd just have to rotate an object by the arctangent of dy/dx (dy/dx = dy/dtheta / dx/dtheta via chain rule). However in 3D space there are 3 axes I can rotate about instead of 1. The goal is to solve for the euler angles (or perhaps another way if there is a better way) I need to rotate this object such that it matches the curve.
I figured that to get the angle I need to rotate about Y, I just need to take the arctangent of dx/dz and the angle to rotate about X seemed to be arctangent of dy/dh where dh/dtheta comes by the pythagorean theorem and attaching the correct sign: as in: dy/dh = dy/dtheta / dh/dtheta where dh/dtheta = sqrt(dx/dtheta^2 + dy/dtheta^2) Although I'd have to manually sign dh/dtheta as the signedness is lost which I have done as: if dx_dtheta has the same sign as dz_dtheta then dh_dtheta = -dh_theta
I'm not sure exactly why this works but it (seems) to work However assuming everything is correct (and it seems to be), my problem now is how would I solve for the angle to rotate about z puu.sh/wbmGr/6d4f953244.png tl;dr I'm trying to smooth out a curve via taking the arctangent of the rate of change but since this is a 3D problem I don't really know exactly how to get all of the angles. I think I got angle about X and Y correct (or so it seems) but don't know how to get the angle about Z
|
|
|
| Report Abuse |
|
|
szkiller
|
  |
| Joined: 21 Feb 2014 |
| Total Posts: 360 |
|
|
| 05 Jun 2017 07:24 PM |
Too much... Math... I can handle Operators and logic... But I cant handle too much math D:
Whenever I see % and ^ I die |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 06 Jun 2017 12:23 AM |
omg cntkillme is asking for help
this math is beyond 99% of the people on this forum, including me
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 06 Jun 2017 03:39 AM |
omg cntkillme is asking for help [2]
im not intelligent enough, understandable have a nice day |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Jun 2017 04:25 AM |
| I mean it's just what you'd learn in any high school calculus course. The problem is that it's a 3D problem aaaaaa |
|
|
| Report Abuse |
|
|
szkiller
|
  |
| Joined: 21 Feb 2014 |
| Total Posts: 360 |
|
|
| 06 Jun 2017 04:28 AM |
Too much math
Aaaaaaaa
Kill me pls |
|
|
| Report Abuse |
|
|
dance1211
|
  |
| Joined: 09 Apr 2008 |
| Total Posts: 1091 |
|
|
| 06 Jun 2017 04:58 AM |
The solution is you need another equation phi(theta) that represents the roll of the path the parametric equation curve is taking. If you imagine a roller coaster, you can have the track go in a perfectly straight line or you can have the train roll around it. We are trying to find the equation of the rotation as a function of theta (more specifically as a function of x,y,z and phi) because if we don't have phi, we lose a degree of freedom that we desperately need to make this smooth. What is this phi we're looking for? It is the function such that dr/dtheta (where r is the rotation vector) is minimised over some measure we want. That means the the rotation is as smooth as possible. The best example is when in the loop as it goes up, you have that big rotation. We want the rotation to be as small as possible.
So what you are looking for right now is if your current rotation vector is (X,Y,Z) where X,Y,Z are your current functions of theta that give you your rotation values, you need (X,Y,Z + phi(theta) instead.
I'll message you later about how to calculate phi using numerical methods |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Jun 2017 05:44 AM |
let me ask my math teacher
#code print("oh no an errorz!") |
|
|
| Report Abuse |
|
|
Stilect
|
  |
| Joined: 04 Nov 2015 |
| Total Posts: 10857 |
|
|
| 06 Jun 2017 05:48 AM |
| We're not calculators. off. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Jun 2017 08:43 PM |
| Some of the problems I've been having is because I forgot that arctangent's range is between -pi/2 and pi/2... aaaaaaaaaaaaaaaaaaa |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2017 09:11 PM |
Not sure if this is what you are going for, but you can try looking into a TNB-Frame (Google it, Frenet-Serret).
Roblox actually offers a generally accurate function for retrieving angles: CFrame:toEulerAnglesXYZ().
Also, to address issues with arctangent, use math.atan2(x,y). It handles the cases when x and/or y are negative. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Jun 2017 01:36 AM |
| Yes but again that's not the problem. That just happens to be one of them. And toEulerAnglesXYZ is useless because if I was able to get the angles it would mean I would have the correct CFrame to begin with. |
|
|
| Report Abuse |
|
|