|
| 13 Mar 2012 10:07 AM |
I've heard that, :lerp would find out points between 2 vector 3s... I've heard that, people told me that you could use :slerp(), and that it is very similar to :lerp() but for rotation.
So... would you use it like this? local newrot = oldrot:slerp(endrot, ratio) ?
So do you just use one starting rotation, and one ending rotation?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Mar 2012 10:44 AM |
| It's not a real method. You would have to write your own slerp method. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 13 Mar 2012 11:41 AM |
So... I just use CFrame values between slerps?
Pretty confusing... can I just have the wiki link please?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Mar 2012 11:55 AM |
Google "slerp"
er
http://en.wikipedia.org/wiki/Slerp |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2012 11:56 AM |
Oh, ok then. I thought he meant in the ROBLOX wiki.
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2012 12:04 PM |
Uggh, umm... I think it's the geometric slerp... I'm terrible at maths uggh.
Slerp has a geometric formula independent of quaternions, and independent of the dimension of the space in which the arc is embedded. This formula, a symmetric weighted sum credited to Glenn Davis, is based on the fact that any point on the curve must be a linear combination of the ends. Let p0 and p1 be the first and last points of the arc, and let t be the parameter, 0 ≤ t ≤ 1. Compute Ω as the angle subtended by the arc, so that cos Ω = p0 ∙ p1, the n-dimensional dot product of the unit vectors from the origin to the ends. The geometric formula is then
The symmetry can be seen in the fact that Slerp(p0, p1; t) = Slerp(p1, p0; 1 − t). In the limit as Ω → 0, this formula reduces to the corresponding symmetric formula for linear interpolation,
A Slerp path is, in fact, the spherical geometry equivalent of a path along a line segment in the plane; a great circle is a spherical geodesic.
So... Ω would be the rotation right? I feel like an idiot right now... lol. Can someone just give me the function for slerp?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 13 Mar 2012 01:19 PM |
No offense but slerp doesn't sound straight... /diary |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 13 Mar 2012 01:41 PM |
| Everybody got their secrets :3 |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 13 Mar 2012 02:07 PM |
@oysi:
> And to avoid some confusion from what you've probably heard, the reason slerp works with cframe interpolation isn't because roblox "fixes" cframes for you, it's from a simple fact: > If the three unit vectors of each cframe are perpendicular with the other ones in their cframe, the slerping will result in the outcome (3 vectors) being perpendicular as well.
This is false, and I can prove it. Take the simple case of rotation around the line x = y = z by 120 degrees. Our matrix goes from
[1 0 0] [0 1 0] [0 0 1]
to
[0 1 0] [0 0 1] [1 0 0]
This should be fairly self explanatory
---
Now, try slerping halfway between these. Calculated in my head, this gives:
[0.707 0.707 0.000] [0.000 0.707 0.707] [0.707 0.000 0.707]
Again, all these seem correct
---
Now for the proof. If the matrix is orthogonal, then I can pick any two columns, and they will be perpendicular. To test for this, check that `a:Dot(b) == 0`
[0.707, 0, 0.707] · [0.707, 0.707, 0] = 0.707² + 0*0.707 + 0.707*0 = 0.5
There. Proof. The unit vectors of the slerped CFrame are _not_ by nature perpendicular, so something else (i.e. roblox) must be orthogonalizing them.
|
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 13 Mar 2012 09:59 PM |
Thanks Oysi, I'm terrible at maths, I must say that, some people here are pretty good with maths. I wanted to make an animator tool, but since ROBLOX broke the original one, I had to make a new one that would just work with CFrames...
So, I just use it like :lerp() right?
Anyways: function slerp(a, b, t) local r = math.acos(a:Dot(b)) return (a*math.sin((1 - t)*r) + b*math.sin(t*r)) / math.sin(r) end
function Rotate() local t = 1 for 1, 1, 10 do local newrot = slerp(angle1, angle 2, t) brick.CFrame = newrot t = t + 1 wait() end
right?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
|
| 14 Mar 2012 01:27 PM |
I made a script sort of similar to lerp a while ago for robots. I thought that it seemed they could only move about 20 studs at a time without stopping, so I used it to split lines into equal chunks all less than 20 studs apart.
~- Commander of the Heavy Assault Robloxian Army. Join today! -~ |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
L3GabeL4
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 808 |
|
|
| 14 Mar 2012 01:54 PM |
try this...
function slerp(a, b, t) local r = math.acos(a:Dot(b)) return (a*math.sin((1 - t)*r) + b*math.sin(t*r)) / math.sin(r) end
function Rotate() local t = 1 for 1, 1, 10 do local newrot = slerp(angle1, angle 2, t) brick.CFrame = newrot t = t + 1 wait() end
"God created us, and he will end us" - eminem |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 14 Mar 2012 05:10 PM |
| newrot isn't even a cframe, so it wouldn't work even if it was being used correctly |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 14 Mar 2012 06:31 PM |
| When I read "Geometric Slerp" on the wikipedia, I laughed hysterically in my head. |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2012 01:19 PM |
Hmm... Is this correct?
function slerp(a, b, t) local r = math.acos(a:Dot(b)) return (a*math.sin((1 - t)*r) + b*math.sin(t*r)) / math.sin(r) end
function Rotate() local t = 1 for 1, 1, 10 do local newrot = CFrame.new(slerp(angle1, angle 2, t)) brick.CFrame = newrot t = t + 1 wait() end
Or
function Rotate() local t = 1 for 1, 1, 10 do local newrot = slerp(angle1, angle 2, t) brick.CFrame = CFrame.new(newrot) t = t + 1 wait() end
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 15 Mar 2012 01:45 PM |
I asked scripters helpers for this a bit, still haven't got an ACTUAL function...
Stravent said: --- Use the Slerp function off of Wikipedia, and apply that to all three unit vectors of the CFrame: local function Slerp(t, a, b) local om = math.acos(a:Dot(b)) return (math.sin((1-t)*om)/math.sin(om))*a + (math.sin(t*om)/math.sin(om))*b end
Combined with: local function CFrameFromUnitVectors(p, right, top, back) --local R = {CFrame:components()} --Position = ( R[1], R[2], R[3] ) --RightVector = ( R[4], R[7], R[10] ) --TopVector = ( R[5], R[8], R[11] ) --BackVector = ( R[6], R[9], R[12] ) return CFrame.new(p.x, p.y, p.z, right.x, top.x, back.x, right.y, top.y, back.y, right.z, top.z, back.z) end
Taken form this WIP new cart track "fill" tool of mine, only one that works with tracks at completely arbitrary orientations so you can make actual rollercoasters with it: [ URL Withheld ]
Make things called "tie" and put them into the "track_ties" model that it generates, then select the "A" button in it's toolbar and select a tie, hold "2" and select a tie to join it to.
It doesn't do any explicit tweening, since I need finer control than that, but it does a lot of the same kinds of things that you probably want to do. ---
Which totally confused me. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|