(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > Submissions

Submissions Submit JASS resources! If approved, they will be moved to their proper section.
Please read me first.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 06-24-2008, 03:53 AM   #1 (permalink)
Model Moderator
 
BlinkBoy's Avatar

User
 
Join Date: Nov 2004
Posts: 760

BlinkBoy is a jewel in the rough (199)BlinkBoy is a jewel in the rough (199)


Interpolation Functions

I have shared with many these functions, but I had never posted them officially:

library Interpolation

function Linear takes real a, real b, real t returns real
         return a + (b-a)*t
    endfunction

// Bezier Interpolation: Bezier_[Point_number]

    function Bezier_3 takes real a, real b, real c, real t returns real
         return a + 2*(b-a)*t + (c -2*b + a)*t*t
endfunction //Uses 3 points

//You can use Bezier 3 to graphic perfect parabols

    function Bezier_4 takes real a, real b, real c, real d, real t returns real
    local real m = t*t
        return a + 3*t*(b - a) + 3*m*(c - 2*b + a) + m*t*(3*(b-c) + d - a)
    endfunction //Uses 4 points

//Bezier_4(<Start Point>, <OutTan_of_StartPoint>, <InTan_of_EndPoint>, <EndPoint>)

//Hermite Interpolation
    function Hermite takes real p1, real p2, real t1, real t2, real s returns real
        local real s2 = s*s
        local real h1 = 8.0*s*s2 - 9.0*s2
        local real h2 = h1*(-1)
        local real h3 = s2*(s - 2.0) + s
        local real h4 = s2*(s - 1.0)
        set h1 = h1 + 1
        return h1*p1 + h2*p2 + h3*t1 + h4*t2
    endfunction
//Hermite(<StartPoint>,<EndPoint>,<Tangent1>,<Tangent2>)

    function GetCardTan takes real p1, real p3 returns real
       return 0.5*(p3-p1)
    endfunction

// TCB functions for finding the tangents among 3 points
// Most modellers may know TCB from 3dsmax, in which they are used to make rotations
// look very smooth.
// t = tension, c = continuity, b = bias
// tension is how sharply the curve makes turns.
// continuity specifies the rate of change between speed and direction.
// bias specifies the direction of the curve.
// sidenote: specify p1 as 0, when working with 2 points.

// the next function returns the intan of p2

function InTan takes real p1, real p2, real p3, real t, real c, real b returns real
           return (1.0-t)*(1.0-c)*(1.0+b)*(p2-p1)/2 + (1.0-t)*(1.0+c)*(1.0-b)*(p3-p2)/2
    endfunction

// the next function returns the outtan of p2

    function OutTan takes real p1, real p2, real p3, real t, real c, real b returns real
           return (1.0-t)*(1.0+c)*(1.0+b)*(p2-p1)/2 + (1.0-t)*(1.0-c)*(1.0-b)*(p3-p2)/2
    endfunction
//These functions do conversions between 3dsmax TCB system and normal TCB
//3dsmax's is a lot more linear and easier to edit than the others
//Insert any value like tension, continuity or bias.
    function Max2TCB takes real value returns real
           return (value-25.)/25.
    endfunction

    function TCB2Max takes real value returns real
           return value*25. +25.
    endfunction
endlibrary

These famous functions are used by Blizzard and most game makers to interpolate among keys within models, in a very fast way.

Reminder All this functions should be use on Axis individually, which is good if you want to convine different interpolations. You can interpolate anything with these, from distances to accelerations.
BlinkBoy is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change bezier interpolation to linear in .mdl file? LazyCoder Modeling & Animation 4 06-19-2008 07:44 PM
[JASS] Global Functions (Reusable Functions) Tigershark Triggers & Scripts 6 05-25-2008 03:37 AM
[JASS] Or/And functions bugging out Herman Triggers & Scripts 4 03-18-2008 12:31 AM
[JASS] Two functions calling each other... Preskooldude Triggers & Scripts 8 02-07-2008 03:48 PM
[JASS] Functions... NoNZealot Triggers & Scripts 4 10-20-2007 09:38 PM

All times are GMT. The time now is 08:45 AM.






Your link here 
Agencia de turismo | Debt Consolidation | Ringtones | Hen Night | Lingerie
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle