Thread: Beiser Curves
View Single Post
  #1  
Old 01-19-2011, 12:49 AM
dabblercody dabblercody is offline
Tech Assistant
dabblercody's Avatar
Join Date: May 2006
Location: Florida
Posts: 22
dabblercody is on a distinguished road
Beiser Curves

I've recently been trying to figure how to correctly implement this into Graal. I've also been trying to improve my math-based scripting. This is a sample script I had to test the outcome of the 4 given points. The solution I get is x1 and x2 = 5.82375. I just need to find out if this is correct? And if it isn't what is the correct way of doing it, and how can I improve onto my knowledge of scripting? In case your wondering how I got the variable t. And yes I spelled Beiser wrong it should be Bezier.

The t parameter (varying from 0 to 1) cuts the P1-P4 segment to intervals, according to the wanted accuracy.
When t = 0 results are t(x1) = P1(x1) and t(x2)= P1(x2)
When t = 1 results are t(x1) = P4(x1) and t(x2)= P4(x2)


PHP Code:
//#CLIENTSIDE
function onPlayerChats()
{
 if (
player.chat == "/curve")
 {
  
Beiser2D();
 }
}

function 
Beiser2D()
{
 
t = .05;
 
a = 5;  // p1
 
b = 10; // p2
 
c = 25; // p3
 
d = 40; // p4
 
x1 = (1 - t)^3 * a + 3 * (1 - t)^2 * t * b + 3 * (1 - t) * t^2 * c + t^3 * d;
 
x2 = (1 - t)^3 * a + 3 * (1 - t)^2 * t * b + 3 * (1 - t) * t^2 * c + t^3 * d;
 
player.chat = "Solution is:" SPC x1 SPC "/" SPC x2;
} 
The Formulas are:
PHP Code:
t(x1) = (1-t)3  x P1x + 3 x (1-t)2 x t x P2x + 3 x (1-t) x t2 x P3x + t3 x P4x 
t
(x2) = (1-t)3  x P1y + 3 x (1-t)2 x t x P2y + 3 x (1-t) x t2 x P3y + t3 x P4y 
__________________
Dabbler

"Our work is the presentation of our capabilities."
- Goethe, Johann Wolfgang Von

Last edited by dabblercody; 01-19-2011 at 01:10 AM..
Reply With Quote