OH RIGHT! The # sign! I totally forgot x.x I've got it working in C++.. figured it was a type issue. I'm so used to strictly defining types..
Much thanks to the both of you!
Now of course.. onto more trigonometry that I never bothered trying to learn way back when xP
Let's say I want to draw a circle by hand by specifying the dots.
is ringing a bell, though I doubt I got it right. o.o
I'm assuming if I just sat down here.. and if that circle was right.. I could make a camera orbit a point finally!
[EDIT]So, here's what we have. The DBP version still has the issue of closer to 0, the dots become more sparse and when negative, they no longer draw (and just to add to the confusion, the C++ version works flawlessly with negative values and approaching 0).
DBP:
x1 = screen width()/2.0
y1 = screen height()/2.0
do
cls
ink rgb(255,255,255),0
x2 = mousex()
y2 = mousey()
//line x1,y1,x2,y2 //Does the same as the Lerp dot drawing
for x = x1 to x2
//dot x,Lerp(y1,y2,(x-x1*1.0)/(x2-x1*1.0))
dot x,CosLerp(y1,y2,(x-x1*1.0)/(x2-x1*1.0))
next x
ink rgb(255,0,0),0
circle x1,y1,5
circle x2,y2,5
loop
end
function Lerp(a#,b#,x#)
ret# = x# * (b# - a#) + a#
endfunction ret#
function CosLerp(a#,b#,x#)
f# = (1 - cos(x#*180.0))*0.5
ret# = f# * (b# - a#) + a#
endfunction ret#
C++:
//Compiled using MinGW: g++ Lerp.cpp -o Lerp.exe
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
float Lerp(float from,float to,float x)
{
return x * (to - from) + from;
}
float CosLerp(float from,float to,float x)
{
float f = (1 - cos(x * 3.14159265)) * .5;
return f * (to - from) + from;
}
void handle()
{
float f,t,x;
char in;
cout << "Lerp Test" << endl << "What would you like to do?" << endl;
cout << "\t1. Lerp \n\t2. CosLerp \n\t3. Exit" << endl;
cin >> in;
switch(in)
{
case '1':
cout << "From: ";
cin >> f;
cout << endl << "To: ";
cin >> t;
cout << endl << "Ratio: ";
cin >> x;
cout << endl << "Result: " << Lerp(f,t,x) << endl;
break;
case '2':
cout << "From: ";
cin >> f;
cout << endl << "To: ";
cin >> t;
cout << endl << "Ratio: ";
cin >> x;
cout << endl << "Result: " << CosLerp(f,t,x) << endl;
break;
case '3':
exit(0);
break;
default:
exit(0);
break;
}
}
int main(int argc,char* argv[])
{
while(1)
{
handle();
}
return 0;
}
Your signature has been erased by a mod - Please change your "moddy freak out" size to 600x240px. Thanks