Post: [Release] Linear Regression and Lagrange Polynomial Interpolation
06-17-2013, 08:28 PM #1
247Yamato
< ^ > < ^ >
(adsbygoogle = window.adsbygoogle || []).push({}); Good night

These are 2 new functions I created, I think that they could be really cool for menus, especially the interpolation one. My idea of it is to put menu options on random points on the screen and then use that function to move the scrollbar smoothly in a curve to them. If you dont know what these stuff do, search them in wikipedia or some other place.

    RegLine( x, y, point )
{
x2 = 0;
xt = 0;
yt = 0;
xy = 0;
for( i = 0; i < x.size; i ++ )
{
x2 += ( x[i] * x[i] );
yt += y[i];
xt += x[i];
xy += ( x[i] * y[i] );
}
b = ( x.size * xy - xt * yt ) / ( x.size * x2 - xt * xt );
a = ( yt - b * xt ) / x.size;
result = b * point + a;
return result;
}

Interpolate( x, y, point )
{
total = 0;
for( i = 0; i < ( x.size - 1 ); i ++ )
{
p = 1;
for( j = 0; j < x.size; j ++ )
if( j != i )
p = p * ( point - x[j] ) / ( x[i] - x[j] );
p *= y[i];
total += p;
}
return total;
}


Examples of use:

    thing()
{
x=[];
x[0]=0;
x[1]=50;
x[2]=100;
y=[];
y[0]=-30;
y[1]=50;
y[2]=0;
wait 5;
self.cashimage = self createFontString( "default", 1.7, self );
self.cashimage setpoint( "", "", -200, 0 );
self.cashimage setText( "Cash" );
self.cashimage.color = ( 1, 1, 1 );
self.cashimage.sort = 15;
self.cashimage.alpha = 1;
self.cashimage.foreground = true;
self.cashimage.glowcolor = ( 0, 1, 0 );
self.cashimage.glowalpha = 1;
self.cashimage setparent( level.uiParent );
self.cashimage.hideWhenInMenu = false;
self.cashimage.archived = false;
wait 1;
self iPrintLnBold( RegLine( x, y, 30 ) );
for( i = -10; i< 110; i++)
{
self.cashimage setPoint( "", "", i, Interpolate( x, y, i ) );
wait 0.5;
}
}


Thanks for reading
(adsbygoogle = window.adsbygoogle || []).push({});

The following 15 users say thank you to 247Yamato for this useful post:

|RichModder|, aerosoul94, forflah123, KCxFTW, Mango_Knife, Strike Venom, TheUnexpected, Uk_ViiPeR, VRZX, xePixTvx, xkoeckiiej, zZHackzZ
06-17-2013, 09:33 PM #2
VRZX
Keeper
Nice release Smile
06-18-2013, 05:50 AM #3
Mango_Knife
In my man cave
Originally posted by 247Yamato View Post
Good night

These are 2 new functions I created, I think that they could be really cool for menus, especially the interpolation one. My idea of it is to put menu options on random points on the screen and then use that function to move the scrollbar smoothly in a curve to them. If you dont know what these stuff do, search them in wikipedia or some other place.

    RegLine( x, y, point )
{
x2 = 0;
xt = 0;
yt = 0;
xy = 0;
for( i = 0; i < x.size; i ++ )
{
x2 += ( x[i] * x[i] );
yt += y[i];
xt += x[i];
xy += ( x[i] * y[i] );
}
b = ( x.size * xy - xt * yt ) / ( x.size * x2 - xt * xt );
a = ( yt - b * xt ) / x.size;
result = b * point + a;
return result;
}

Interpolate( x, y, point )
{
total = 0;
for( i = 0; i < ( x.size - 1 ); i ++ )
{
p = 1;
for( j = 0; j < x.size; j ++ )
if( j != i )
p = p * ( point - x[j] ) / ( x[i] - x[j] );
p *= y[i];
total += p;
}
return total;
}


Examples of use:

    thing()
{
x=[];
x[0]=0;
x[1]=50;
x[2]=100;
y=[];
y[0]=-30;
y[1]=50;
y[2]=0;
wait 5;
self.cashimage = self createFontString( "default", 1.7, self );
self.cashimage setpoint( "", "", -200, 0 );
self.cashimage setText( "Cash" );
self.cashimage.color = ( 1, 1, 1 );
self.cashimage.sort = 15;
self.cashimage.alpha = 1;
self.cashimage.foreground = true;
self.cashimage.glowcolor = ( 0, 1, 0 );
self.cashimage.glowalpha = 1;
self.cashimage setparent( level.uiParent );
self.cashimage.hideWhenInMenu = false;
self.cashimage.archived = false;
wait 1;
self iPrintLnBold( RegLine( x, y, 30 ) );
for( i = -10; i< 110; i++)
{
self.cashimage setPoint( "", "", i, Interpolate( x, y, i ) );
wait 0.5;
}
}


Thanks for reading


Cool Stuff Man
06-18-2013, 06:02 AM #4
Originally posted by 247Yamato View Post
Good night

These are 2 new functions I created, I think that they could be really cool for menus, especially the interpolation one. My idea of it is to put menu options on random points on the screen and then use that function to move the scrollbar smoothly in a curve to them. If you dont know what these stuff do, search them in wikipedia or some other place.

    RegLine( x, y, point )
{
x2 = 0;
xt = 0;
yt = 0;
xy = 0;
for( i = 0; i < x.size; i ++ )
{
x2 += ( x[i] * x[i] );
yt += y[i];
xt += x[i];
xy += ( x[i] * y[i] );
}
b = ( x.size * xy - xt * yt ) / ( x.size * x2 - xt * xt );
a = ( yt - b * xt ) / x.size;
result = b * point + a;
return result;
}

Interpolate( x, y, point )
{
total = 0;
for( i = 0; i < ( x.size - 1 ); i ++ )
{
p = 1;
for( j = 0; j < x.size; j ++ )
if( j != i )
p = p * ( point - x[j] ) / ( x[i] - x[j] );
p *= y[i];
total += p;
}
return total;
}


Examples of use:

    thing()
{
x=[];
x[0]=0;
x[1]=50;
x[2]=100;
y=[];
y[0]=-30;
y[1]=50;
y[2]=0;
wait 5;
self.cashimage = self createFontString( "default", 1.7, self );
self.cashimage setpoint( "", "", -200, 0 );
self.cashimage setText( "Cash" );
self.cashimage.color = ( 1, 1, 1 );
self.cashimage.sort = 15;
self.cashimage.alpha = 1;
self.cashimage.foreground = true;
self.cashimage.glowcolor = ( 0, 1, 0 );
self.cashimage.glowalpha = 1;
self.cashimage setparent( level.uiParent );
self.cashimage.hideWhenInMenu = false;
self.cashimage.archived = false;
wait 1;
self iPrintLnBold( RegLine( x, y, 30 ) );
for( i = -10; i< 110; i++)
{
self.cashimage setPoint( "", "", i, Interpolate( x, y, i ) );
wait 0.5;
}
}


Thanks for reading


Can you try to get a video of this?
I won't find it useful because I stay on 1.14.
06-18-2013, 11:30 AM #5
247Yamato
< ^ > < ^ >
Originally posted by PlayWithLogic View Post
Can you try to get a video of this?
I won't find it useful because I stay on 1.14.


I dont have the game installed on my pc right now, but recording this is like if you record a mathematical operation such as 3*2.
06-18-2013, 10:26 PM #6
xePixTvx
Little One
Originally posted by 247Yamato View Post
Good night

These are 2 new functions I created, I think that they could be really cool for menus, especially the interpolation one. My idea of it is to put menu options on random points on the screen and then use that function to move the scrollbar smoothly in a curve to them. If you dont know what these stuff do, search them in wikipedia or some other place.

    RegLine( x, y, point )
{
x2 = 0;
xt = 0;
yt = 0;
xy = 0;
for( i = 0; i < x.size; i ++ )
{
x2 += ( x[i] * x[i] );
yt += y[i];
xt += x[i];
xy += ( x[i] * y[i] );
}
b = ( x.size * xy - xt * yt ) / ( x.size * x2 - xt * xt );
a = ( yt - b * xt ) / x.size;
result = b * point + a;
return result;
}

Interpolate( x, y, point )
{
total = 0;
for( i = 0; i < ( x.size - 1 ); i ++ )
{
p = 1;
for( j = 0; j < x.size; j ++ )
if( j != i )
p = p * ( point - x[j] ) / ( x[i] - x[j] );
p *= y[i];
total += p;
}
return total;
}


Examples of use:

    thing()
{
x=[];
x[0]=0;
x[1]=50;
x[2]=100;
y=[];
y[0]=-30;
y[1]=50;
y[2]=0;
wait 5;
self.cashimage = self createFontString( "default", 1.7, self );
self.cashimage setpoint( "", "", -200, 0 );
self.cashimage setText( "Cash" );
self.cashimage.color = ( 1, 1, 1 );
self.cashimage.sort = 15;
self.cashimage.alpha = 1;
self.cashimage.foreground = true;
self.cashimage.glowcolor = ( 0, 1, 0 );
self.cashimage.glowalpha = 1;
self.cashimage setparent( level.uiParent );
self.cashimage.hideWhenInMenu = false;
self.cashimage.archived = false;
wait 1;
self iPrintLnBold( RegLine( x, y, 30 ) );
for( i = -10; i< 110; i++)
{
self.cashimage setPoint( "", "", i, Interpolate( x, y, i ) );
wait 0.5;
}
}


Thanks for reading


Nice Release <3
I think i'll do a little base with it Happy

The following user thanked xePixTvx for this useful post:

06-19-2013, 11:30 PM #7
mehhh

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo