Petr Schreiber
01-10-2006, 11:51
Hi,
few days ago I had a chat with a friend about his homework, and we could not arrange, how on the earth the
y = ArcCos(x+1)-Pi function looks :)
If you want to avoid this problems ( especially in homeworks ), you could try attched "FunctionPlotting" script.
How to use it ? You can display up to 6 functions in one screen. They will have different colors and you can zoom in and out.
To define function, you just have to edit function slots in the source.
Here is sample for COS function:
function functionDefinition5( byval x as ext )
FunctionDescription(5) = "y = cos(x)"
local y as single
' If no condition, it will be calculated for all the range
y = cos(x)
tbgl_Vertex x,y,0
end function
... this function will be called and rendered by program "engine". Nothing complicated.
If you want to render function with some limits in paramteres, you can do it this way:
function functionDefinition1( byval x as ext )
FunctionDescription(1) = "y = arccos(x)"
local y as single
' Condition for drawing, range of function
' <-1, 1>
if x >= -1 and x <= 1 then
y = arccos(x) ' Function formula
tbgl_Vertex x,y,0 ' This will add next part of plot
end if
end function
... as you can see, it is nothing complicated.
Hope it will help you when you'll be in doubt, how some function looks...
Petr
few days ago I had a chat with a friend about his homework, and we could not arrange, how on the earth the
y = ArcCos(x+1)-Pi function looks :)
If you want to avoid this problems ( especially in homeworks ), you could try attched "FunctionPlotting" script.
How to use it ? You can display up to 6 functions in one screen. They will have different colors and you can zoom in and out.
To define function, you just have to edit function slots in the source.
Here is sample for COS function:
function functionDefinition5( byval x as ext )
FunctionDescription(5) = "y = cos(x)"
local y as single
' If no condition, it will be calculated for all the range
y = cos(x)
tbgl_Vertex x,y,0
end function
... this function will be called and rendered by program "engine". Nothing complicated.
If you want to render function with some limits in paramteres, you can do it this way:
function functionDefinition1( byval x as ext )
FunctionDescription(1) = "y = arccos(x)"
local y as single
' Condition for drawing, range of function
' <-1, 1>
if x >= -1 and x <= 1 then
y = arccos(x) ' Function formula
tbgl_Vertex x,y,0 ' This will add next part of plot
end if
end function
... as you can see, it is nothing complicated.
Hope it will help you when you'll be in doubt, how some function looks...
Petr