## re:plotting points

Expand Messages
• I wrote this to plot lines or parabolas. It is easy to follow if you can use it. Marc NOMAINWIN global pressedq global st44\$ global axminus global axplus Menu
Message 1 of 5 , Apr 4, 2010
I wrote this to plot lines or parabolas. It is easy to follow if you can use it.
Marc
NOMAINWIN

global pressedq
global st44\$
global axminus
global axplus

WindowWidth = 250
WindowHeight = 250
button #mwin, "y=mx+b", [linear1], LR, 170, 10
button #mwin, "y=ax^2+bx+c", [quadratic], LR, 90, 10
UpperLeftX = int(( DisplayWidth - WindowWidth ) / 2)
UpperLeftY = int(( DisplayHeight - WindowHeight ) / 2)
open "Graphing V 1.01" for Window_nf as #mwin

print #mwin, "trapclose [quit3]"

wait
prompt "Enter quadratic equation in form y=ax^2+bx+c";st44\$
pressedq = 99

close #mwin
if pressedq = 99 goto [quad44]

wait
Notice "QUADv1.01 ";chr\$(13);"By m f r 2010"

wait

[linear1]

ystringtouse1\$ = getinputin\$(string22\$)

notice ystringtouse1\$

goto [c]

function getinputin\$(string11\$)
PROMPT "Enter equation as y=rise/runx+b:";st1\$
getinputin\$ = st1\$
end function

[c]
rem
call enterstring1\$ ystringtouse1\$, stringtouse1\$,stringtouse2\$,stringtouse3\$, stringtouse4\$
rem
close #mwin
call graphicsuse

print #main, "trapclose [quit2]"
print #main, "up;home;north;turn 270;go 10;north;turn 180;go 10;north"
' graph yintercept

yi = val(stringtouse4\$) ' stringtouse4\$ is the yintercept
y = (-1 * 1) ' compiler negation
while y < yi
if y <> yi then
gup = gup + 2
end if
if y = yi then
exit while
end if
y = y + .1
wend
print #main, "up;go ";gup
print #main, "down;color BLUE;circle 5"
print #main, "posxy yintx1 yinty1" ' keep posistion of the first point (yint)and go from here
print #main, "up"
rem graph the rise negative or positive
rise = val(stringtouse1\$)
falserise = abs(rise)
t = 0
if rise < 0 then
while t < falserise ' rise is negative
if t <> rise then
negpos = negpos + 2
end if
if t = rise then
exit while
end if
t = t + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the second point(rise) and go from here
print #main, "north;turn 180;go ";negpos

end if
u = 0
if rise > 0 then
while u < rise
if u <> rise then
pospos = pospos + 2
end if
if u = rise then
exit while
end if
u = u + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the third point(run) and go from here
print #main, "north;go ";pospos

end if
' graph run point
run12 = val(stringtouse2\$)
v = 0
while v < run12
if v <> run12 then
gorun = gorun + 2
end if
if v = run12 then
exit while
end if
v = v + .1
wend
print #main, "up;north;turn 90;go ";gorun
print #main, "down;circle 5;up"
print #main, "posxy runx2 runy2" ' keep posistion of the third point(run) and go from here
print #main, "down"
print #main, "place ";yintx1; " ";yinty1
print #main, "goto "; runx2; " ";runy2
print #main, "up"
rem *************start
if rise < 0 then ' this is negative rise going DOWN on the third point
print #main, "place ";runx2; " ";runy2
print #main, "north;turn 180"
while r < falserise
if falserise <> r then
goagain = goagain + 2
end if
if falserise = r then
exit while
end if
r = r + .1
wend
print #main, "go ";goagain
' this is the virtual DOWN
print #main, "up"

call gotofinalpoint run12

print #main, "posxy vx2 vy2"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";vx2; " ";vy2
end if
' everthing above this line is ok ********************************************************************************

if rise > 0 then ' third point pos rise
rem **********************************last

print #main, "north" ' this is the rise of positive number UP on the third point
while e < rise
if rise <> e then
goagainlast = goagainlast + 2
end if
if rise = e then
exit while
end if
e = e + .1
wend
print #main, "go ";goagainlast
print #main, "up"
call gotofinalpoint run12
print #main, "posxy lastx lasty"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";lastx; " ";lasty
print #main, "FLUSH"
end if

wait

sub gotofinalpoint therise ' this sub is the run over to the right
print #main, "north;turn 90"
w = 0
while w < therise
if w <> therise then
go = go + 2
end if
if w = therise then
exit while
end if
w = w + .1
wend
print #main, "go ";go
print #main,"down;circle 5"

end sub

wait

wait

rem
sub enterstring1\$ ystring\$, byref st1\$,byref st2\$,byref st3\$,byref st4\$
rem
rem get rise
a = instr(ystring\$,"=")
c = instr(ystring\$,"/")
d = instr(ystring\$,"x")
e = instr(ystring\$, "+")
f = instr(ystring\$, "-")

rem y=123/34x-5
b = a + 1
st1\$ = mid\$(ystring\$,b,c-b) ' from = sign to / sign
rem get run
st2\$ = mid\$(ystring\$,c+1 , (d-c)-1) ' from / sign to "x"

get4\$ = mid\$(ystring\$, 4,7)
negy = instr(get4\$, "-")
if negy > 0 then
st3\$ = "-" ' sign of yintercept
end if
if negy = 0 then
st3\$ = "+"
end if
st4\$ = mid\$(ystring\$, d + 1,3)
end sub

wait

' rem start quadratic equation solving

call getquadratic\$ st44\$, aone\$, bone\$, cone\$

call getsign\$ aone\$, bone\$, cone\$,sign1\$, sign2\$, sign3\$
rem assign global variables to use in graphics
rem if x is neg use else skip
if mid\$(aone\$,1,1) = "-" then ' if it is a negative quadratic equation the next lines (turn the signs)
havetoreverse = 8888
turnpos1 = val(aone\$)
turnpos2 = val(bone\$)
turnpos3 = val(cone\$)
x1 = turnpos1 * -1
x2 = turnpos2 * -1
x3 = turnpos3 * -1
newaone\$ = str\$(x1)
newbone\$ = str\$(x2)
newcone\$ = str\$(x3)

aone\$ = newaone\$
bone\$ = newbone\$
cone\$ = newcone\$
end if
rem

rem *************************
gprod1 = product1
gprod2 = product2
rem ****************what product is larger?smaller? ****************
getmax = minmax(gprod1, gprod2,sm,bg)
rem
axplus = bg + 1
axminus = sm - 1
rem ***************************
if havetoreverse = 8888 then
call turnagain\$, aone\$, bone\$, cone\$
end if

rem ****
bigy = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axplus)
rem ************************************
bigy2 = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axminus)
rem ************************************

call getcoordinates\$ aone\$, bone\$, cone\$, axis\$, vertex\$
ver = val(vertex\$)
' **********************************************************************************

goto [xy]

sub getquadratic\$ st444\$,byref aa1\$,byref bb1\$,byref cc1\$
rem y=2x^2+45x+7
rem get a
numgeta = instr(st444\$, "x")
aa1\$ = mid\$(st444\$,3,numgeta-3) ' get a (first number)
rem use a string to cut main string into a short string so as to locate position further in the string as not to get duplicate x
numlook = numgeta + 3
rem y=3x^2+45x+4
shortstring1\$ = mid\$(st444\$, numlook, 11)
findanotherx = instr(shortstring1\$, "x")
bb1\$ = mid\$(shortstring1\$, 1,findanotherx -1 )
moveaheadstring1\$ = mid\$(shortstring1\$, findanotherx + 1, 8)
gets1\$ = mid\$(aa1\$,1,1)
if gets1\$ <> "-" then
s1\$ = "+"
newa1\$ = s1\$+aa1\$
aa1\$ = ""
aa1\$ = newa1\$
end if
end sub

sub getsign\$ byref a1\$, byref b1\$, byref c1\$,byref s1\$, byref s2\$,byref s3\$

s1\$ = left\$(a1\$,1)
s2\$ = left\$(b1\$, 1)
s3\$ = left\$(c1\$, 1)
end sub

sub solvequadratic\$ byref term1\$,byref term2\$,byref term3\$,byref p1,byref p2

a1 = val(term1\$) ' a
b2 = val(term2\$) ' b
c3 = val(term3\$) ' c

rem -b +/- sqr((b^2 (- 4ac))) / 2a
x = (b2 * -1)
x2= sqr((b2^2)+(-4*a1*c3))
p1 = (x + x2) / (2 * a1)
p2 = (x - x2) / (2 * a1)
end sub

sub getcoordinates\$ byref a2\$,byref b2\$,byref c2\$, byref axisofsymmetry\$, byref vertexpoint\$
a2 = val(a2\$)
b2 = val(b2\$)
c2 = val(c2\$)

axisofsymmetry1 = (-1*b2)/(2*a2)
vertexpoint1 = ((4*a2*c2) - (b2^2))/ (4*a2)
axisofsymmetry\$ = str\$(axisofsymmetry1)
vertexpoint\$ = str\$(vertexpoint1)
end sub

rem function to get y values replacing X with different variables to graph

function y(byref a\$, byref b\$,byref c\$,byref s1\$,byref s2\$,byref s3\$,byref x)

firstterm = val(a\$)
secondterm = val(b\$)
thirdterm = val(c\$)
power1 = x^2
atimespower1 = firstterm * power1
t1 = atimespower1
t2 = secondterm * x
if s2\$ = "-" then
common1 = t1 - t2
end if
if s2\$ = "+" then
common1 = t1 + t2 ' first and second term done
end if
if s3\$ = "-" then
common2 = common1 + thirdterm
y=common2
end if
if s3\$ = "+" then
common2 = common1 + thirdterm
y = common2
end if
end function

function minmax(byref vala, byref valb, byref small, byref big)
if vala > valb then
big = vala
small = valb
end if
if valb > vala then
big = valb
small = vala
end if
minmax = big
end function

sub turnagain\$ byref ae\$,byref be\$, byref ce\$
turn1 = val(ae\$)
turn2 = val(be\$)
turn3 = val(ce\$)

toturn1 = turn1 * -1
toturn2 = turn2 * -1
toturn3 = turn3 * -1

ae\$ = str\$(toturn1)
be\$ = str\$(toturn2)
ce\$ = str\$(toturn3)
end sub

sub graphicsuse ' drawing of main grid
WindowHeight = 700
WindowWidth = 700
UpperLeftX=Int((DisplayWidth-WindowWidth)/2) 'This line and the next center the window
UpperLeftY=Int((DisplayHeight-WindowHeight)/2)

Menu #main , "&Print" ,"&Print Graph",[gprint]
open "Graphing" for graphics_nf_nsb as #main
rem the next section draws main grid lines (Thick)
print #main, "place 1 13";"down"
print #main, "\ ";st44\$
'print #main
print #main, "up"
print #main, "size 5"
print #main,"Home;turn 270;go 12"
print #main, "down"
print #main, "north"
print #main, "go 400" ' up
print #main, "up"
print #main, "home;north;turn 270;go 12; turn 270"
print #main, "down;go 400" ' down
' **********************************8
print #main, "up"
print #main, "home;turn 90"
print #main, "down"

print #main, "go 360"
print #main, "up"
print #main, "home;north"
print #main, "down"
print #main, "turn 90"
print #main, "go 360"
print #main, "up;home"
print #main, "north;go 20;turn 90"
print #main, "down"
print #main, "size 1" ' all other lines will be thin
rem to here thick lines (end) section
rem the next few lines draws graphing grid *******************************************************************************************8

for ldraw1 = 1 to 850 step 20
print #main, "place 1 "; ldraw1;"down;go 760"
next ldraw1

for ldraw2 = 1 to 890 step 5
print #main, "place ";ldraw2 ;" 1";"down;turn 90;go 870"
next ldraw2
end sub ' end drawing of main grid
rem
rem

rem coordinates for axis

axisvar = val(axis\$)
rem cone\$ = yintercept
yint = val(cone\$)

rem *************************************** debug it is drawing the yintercept twice I thnk!

[xy]
rem *************************************************** IMPORTANT *******************************************

notice "x(1) =";product1
notice "x(2) =";product2

call graphicsuse

' all graphics done here with automatic counting
' graph axis of symmetry
print #main, "up;home;north;turn 270;go 335;turn 270;go 250;north;turn 90" ' 335 is where to start graphics from exteme left side <----------
cox = adraw1 ' equals the numerical value of the axis

rem draws AXIS OF SYMMETRY ********************************************
a = (-1 * 16)
goacross = 0
while a < cox
if a <> cox then
goacross = goacross + 2
end if
if a = cox then
exit while
end if
a = a + .1
wend

goa = int(goacross)

print #main, "go ";goa

print #main,"down;color RED;north;down;go 500"

print #main, "up;turn 180;go 850" ' graphics pencil at very bottom of screen (y=0) coordinate 640 pixel
print #main, "up;turn 180" ' draw up vertex point
rem draws VERTEX *************************************
goup = 0
d = (-1 * 20) ' = -20
while d < ver
if d <> ver then
goup = goup + 2 ' go up 3 pixels
end if
if d = ver then
exit while ' if equal to vertex exit + draw it
end if
d = d + .1
wend
gp = int(goup) + 200
print #main, "go ";gp
print #main, "down;color BLUE"
print #main, "circle 5"
print #main, "posxy cx cy"

rem graph yintercept **************
rem ******************************** draw yintercept *************************
rem cone\$ = yintercept
yint = val(cone\$)
z = (-1 * 20)
goy = 0
print #main, "up"
print #main, "home;north;turn 270;go 11;turn 270;go 400;turn 180"
while z < yint ' graph yintercept
if z <> yint then
goy = goy + 2
end if
if z = yint then
exit while
end if
z = z + .1
wend
print #main, "go ";goy
print #main, "down;circle 5"
print #main, "posxy yintx yinty"
rem get first sum (x) named product1 positive number ************************************

print #main, "up;home;north;turn 270;go 11;up;turn 180"
prodacross1 = 0
e = 0
while e < product1
if e <> product1 then
prodacross1 = prodacross1 + 2
end if
if e = product1 then
exit while
end if
e = e + .1
wend
pr1 = int(prodacross1)
' for bigy and bigy2

print #main, "up;go ";pr1
print #main, "posxy bigyx bigyy"
print #main, "posxy bx by"
print #main, "down;circle 5"
' positive virtual x
print #main, "up;home;north;turn 270;go 11;up"
rem
f = 0
while f > product2
if f <> product2 then
goback = goback + 2
end if
if f = product2 then
exit while
end if
f = f - .1
wend
pr2 = int(goback)
print #main, "up;go ";pr2

print #main, "down;circle 5"
print #main, "posxy prod2x prod2y"
' for bigy and bigy2
print #main, "posxy bigyx2 bigyy2"
if havetoreverse = 8888 then goto [reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north"
g = 0
while g < bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g + .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy ax ay"
rem get second sum (the negative ) and graph product2 ********************************************
rem position at home North

rem draw virtual x coordinates as given by y function ***************************
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north"
h = 0
while h < bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h + .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy btwox btwoy"

rem ****************************************************************** connect points *************************************
rem ************************************************************************************************************************

print #main, "place ";ax; " ";ay ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";yintx; " ";yinty ' yintercept point
print #main, "goto ";cx; " ";cy
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";btwox;" "; btwoy
print #main, "FLUSH"
wait
[reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north;turn 180"
g = 0
while g > bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g - .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy vx vy"
rem get second sum (the negative ) and graph product2 ********************************************
rem position at home North

rem draw virtual x coordinates as given by y function ***************************
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north;turn 180"
h = 0
while h > bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h - .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy gpx gpy"
rem ********** connect all points
print #main, "place ";vx; " ";vy ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";cx; " ";cy ' vertex
print #main, "goto ";yintx; " ";yinty
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";gpx;" "; gpy
print #main, "FLUSH"
wait
[gprint]
printerdialog

' print #main, "print vga" 'will scale up 600 wide image to full page
print #main, "print svga" 'will scale up 800 wide image to full page
' print #main, "print xga" 'will scale up 1024 wide image to full page

wait
[quit]
close #mwin
end
wait
[quit2]
close #main
end
[quit3]
close #mwin
END
• Marc where r u?  Here USA PA !  I got qs - jes I got qs! Im trying to digest example earlier.   Is there anyone in USA - that can help me w graphics? Say
Message 2 of 5 , Apr 4, 2010
Marc where r u?  Here USA PA !  I got qs - jes I got qs!
Im trying to digest example earlier.   Is there anyone in USA - that can help me w graphics?
Say telephone? Kurt

________________________________
From: Marc <mrossi8888@...>
To: libertybasic@yahoogroups.com
Sent: Sun, April 4, 2010 9:25:02 AM
Subject: [libertybasic] re:plotting points

I wrote this to plot lines or parabolas. It is easy to follow if you can use it.
Marc
NOMAINWIN

global pressedq
global st44\$
global axminus
global axplus

WindowWidth = 250
WindowHeight = 250
button #mwin, "y=mx+b", [linear1], LR, 170, 10
button #mwin, "y=ax^2+bx+c" , [quadratic], LR, 90, 10
UpperLeftX = int(( DisplayWidth - WindowWidth ) / 2)
UpperLeftY = int(( DisplayHeight - WindowHeight ) / 2)
open "Graphing V 1.01" for Window_nf as #mwin

print #mwin, "trapclose [quit3]"

wait
prompt "Enter quadratic equation in form y=ax^2+bx+c" ;st44\$
pressedq = 99

close #mwin
if pressedq = 99 goto [quad44]

wait
Notice "QUADv1.01 ";chr\$(13);" By m f r 2010"

wait

[linear1]

ystringtouse1\$ = getinputin\$( string22\$ )

notice ystringtouse1\$

goto [c]

function getinputin\$( string11\$ )
PROMPT "Enter equation as y=rise/runx+ b:";st1\$
getinputin\$ = st1\$
end function

[c]
rem
call enterstring1\$ ystringtouse1\$ , stringtouse1\$ ,stringtouse2\$ ,stringtouse3\$ , stringtouse4\$
rem
close #mwin
call graphicsuse

print #main, "trapclose [quit2]"
print #main, "up;home;north; turn 270;go 10;north;turn 180;go 10;north"
' graph yintercept

yi = val(stringtouse4\$ ) ' stringtouse4\$ is the yintercept
y = (-1 * 1) ' compiler negation
while y < yi
if y <> yi then
gup = gup + 2
end if
if y = yi then
exit while
end if
y = y + .1
wend
print #main, "up;go ";gup
print #main, "down;color BLUE;circle 5"
print #main, "posxy yintx1 yinty1" ' keep posistion of the first point (yint)and go from here
print #main, "up"
rem graph the rise negative or positive
rise = val(stringtouse1\$ )
falserise = abs(rise)
t = 0
if rise < 0 then
while t < falserise ' rise is negative
if t <> rise then
negpos = negpos + 2
end if
if t = rise then
exit while
end if
t = t + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the second point(rise) and go from here
print #main, "north;turn 180;go ";negpos

end if
u = 0
if rise > 0 then
while u < rise
if u <> rise then
pospos = pospos + 2
end if
if u = rise then
exit while
end if
u = u + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the third point(run) and go from here
print #main, "north;go ";pospos

end if
' graph run point
run12 = val(stringtouse2\$ )
v = 0
while v < run12
if v <> run12 then
gorun = gorun + 2
end if
if v = run12 then
exit while
end if
v = v + .1
wend
print #main, "up;north;turn 90;go ";gorun
print #main, "down;circle 5;up"
print #main, "posxy runx2 runy2" ' keep posistion of the third point(run) and go from here
print #main, "down"
print #main, "place ";yintx1; " ";yinty1
print #main, "goto "; runx2; " ";runy2
print #main, "up"
rem ************ *start
if rise < 0 then ' this is negative rise going DOWN on the third point
print #main, "place ";runx2; " ";runy2
print #main, "north;turn 180"
while r < falserise
if falserise <> r then
goagain = goagain + 2
end if
if falserise = r then
exit while
end if
r = r + .1
wend
print #main, "go ";goagain
' this is the virtual DOWN
print #main, "up"

call gotofinalpoint run12

print #main, "posxy vx2 vy2"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";vx2; " ";vy2
end if
' everthing above this line is ok ************ ********* ********* ********* ********* ********* ********* ********* *****

if rise > 0 then ' third point pos rise
rem ************ ********* ********* ****last

print #main, "north" ' this is the rise of positive number UP on the third point
while e < rise
if rise <> e then
goagainlast = goagainlast + 2
end if
if rise = e then
exit while
end if
e = e + .1
wend
print #main, "go ";goagainlast
print #main, "up"
call gotofinalpoint run12
print #main, "posxy lastx lasty"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";lastx; " ";lasty
print #main, "FLUSH"
end if

wait

sub gotofinalpoint therise ' this sub is the run over to the right
print #main, "north;turn 90"
w = 0
while w < therise
if w <> therise then
go = go + 2
end if
if w = therise then
exit while
end if
w = w + .1
wend
print #main, "go ";go
print #main,"down; circle 5"

end sub

wait

wait

rem
sub enterstring1\$ ystring\$, byref st1\$,byref st2\$,byref st3\$,byref st4\$
rem
rem get rise
a = instr(ystring\$ ,"=")
c = instr(ystring\$ ,"/")
d = instr(ystring\$ ,"x")
e = instr(ystring\$ , "+")
f = instr(ystring\$ , "-")

rem y=123/34x-5
b = a + 1
st1\$ = mid\$(ystring\$ ,b,c-b) ' from = sign to / sign
rem get run
st2\$ = mid\$(ystring\$ ,c+1 , (d-c)-1) ' from / sign to "x"

get4\$ = mid\$(ystring\$ , 4,7)
negy = instr(get4\$, "-")
if negy > 0 then
st3\$ = "-" ' sign of yintercept
end if
if negy = 0 then
st3\$ = "+"
end if
st4\$ = mid\$(ystring\$ , d + 1,3)
end sub

wait

' rem start quadratic equation solving

call getquadratic\$ st44\$, aone\$, bone\$, cone\$

call getsign\$ aone\$, bone\$, cone\$,sign1\$ , sign2\$, sign3\$
rem assign global variables to use in graphics
rem if x is neg use else skip
if mid\$(aone\$,1, 1) = "-" then ' if it is a negative quadratic equation the next lines (turn the signs)
havetoreverse = 8888
turnpos1 = val(aone\$)
turnpos2 = val(bone\$)
turnpos3 = val(cone\$)
x1 = turnpos1 * -1
x2 = turnpos2 * -1
x3 = turnpos3 * -1
newaone\$ = str\$(x1)
newbone\$ = str\$(x2)
newcone\$ = str\$(x3)

aone\$ = newaone\$
bone\$ = newbone\$
cone\$ = newcone\$
end if
rem

call solvequadratic\$ aone\$, bone\$, cone\$,product1, product2

rem ************ ********* ****
gprod1 = product1
gprod2 = product2
rem ************ ****what product is larger?smaller? ************ ****
getmax = minmax(gprod1, gprod2,sm,bg)
rem
axplus = bg + 1
axminus = sm - 1
rem ************ ********* ******
if havetoreverse = 8888 then
call turnagain\$, aone\$, bone\$, cone\$
end if

rem ****
bigy = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axplus)
rem ************ ********* ********* ******
bigy2 = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axminus)
rem ************ ********* ********* ******

call getcoordinates\$ aone\$, bone\$, cone\$, axis\$, vertex\$
ver = val(vertex\$)
' ************ ********* ********* ********* ********* ********* ********* ********* *******

goto [xy]

sub getquadratic\$ st444\$,byref aa1\$,byref bb1\$,byref cc1\$
rem y=2x^2+45x+7
rem get a
numgeta = instr(st444\$ , "x")
aa1\$ = mid\$(st444\$, 3,numgeta- 3) ' get a (first number)
rem use a string to cut main string into a short string so as to locate position further in the string as not to get duplicate x
numlook = numgeta + 3
rem y=3x^2+45x+4
shortstring1\$ = mid\$(st444\$, numlook, 11)
findanotherx = instr(shortstring1\$ , "x")
bb1\$ = mid\$(shortstring1\$ , 1,findanotherx -1 )
moveaheadstring1\$ = mid\$(shortstring1\$ , findanotherx + 1, 8)
gets1\$ = mid\$(aa1\$,1, 1)
if gets1\$ <> "-" then
s1\$ = "+"
newa1\$ = s1\$+aa1\$
aa1\$ = ""
aa1\$ = newa1\$
end if
end sub

sub getsign\$ byref a1\$, byref b1\$, byref c1\$,byref s1\$, byref s2\$,byref s3\$

s1\$ = left\$(a1\$,1)
s2\$ = left\$(b1\$, 1)
s3\$ = left\$(c1\$, 1)
end sub

sub solvequadratic\$ byref term1\$,byref term2\$,byref term3\$,byref p1,byref p2

a1 = val(term1\$) ' a
b2 = val(term2\$) ' b
c3 = val(term3\$) ' c

rem -b +/- sqr((b^2 (- 4ac))) / 2a
x = (b2 * -1)
x2= sqr((b2^2)+( -4*a1*c3) )
p1 = (x + x2) / (2 * a1)
p2 = (x - x2) / (2 * a1)
end sub

sub getcoordinates\$ byref a2\$,byref b2\$,byref c2\$, byref axisofsymmetry\$ , byref vertexpoint\$
a2 = val(a2\$)
b2 = val(b2\$)
c2 = val(c2\$)

axisofsymmetry1 = (-1*b2)/(2*a2)
vertexpoint1 = ((4*a2*c2) - (b2^2))/ (4*a2)
axisofsymmetry\$ = str\$(axisofsymmetry 1)
vertexpoint\$ = str\$(vertexpoint1)
end sub

rem function to get y values replacing X with different variables to graph

function y(byref a\$, byref b\$,byref c\$,byref s1\$,byref s2\$,byref s3\$,byref x)

firstterm = val(a\$)
secondterm = val(b\$)
thirdterm = val(c\$)
power1 = x^2
atimespower1 = firstterm * power1
t1 = atimespower1
t2 = secondterm * x
if s2\$ = "-" then
common1 = t1 - t2
end if
if s2\$ = "+" then
common1 = t1 + t2 ' first and second term done
end if
if s3\$ = "-" then
common2 = common1 + thirdterm
y=common2
end if
if s3\$ = "+" then
common2 = common1 + thirdterm
y = common2
end if
end function

function minmax(byref vala, byref valb, byref small, byref big)
if vala > valb then
big = vala
small = valb
end if
if valb > vala then
big = valb
small = vala
end if
minmax = big
end function

sub turnagain\$ byref ae\$,byref be\$, byref ce\$
turn1 = val(ae\$)
turn2 = val(be\$)
turn3 = val(ce\$)

toturn1 = turn1 * -1
toturn2 = turn2 * -1
toturn3 = turn3 * -1

ae\$ = str\$(toturn1)
be\$ = str\$(toturn2)
ce\$ = str\$(toturn3)
end sub

sub graphicsuse ' drawing of main grid
WindowHeight = 700
WindowWidth = 700
UpperLeftX=Int( (DisplayWidth- WindowWidth) /2) 'This line and the next center the window
UpperLeftY=Int( (DisplayHeight- WindowHeight) /2)

Menu #main , "&Print" ,"&Print Graph",[gprint]
open "Graphing" for graphics_nf_ nsb as #main
rem the next section draws main grid lines (Thick)
print #main, "place 1 13";"down"
print #main, "\ ";st44\$
'print #main
print #main, "up"
print #main, "size 5"
print #main,"Home; turn 270;go 12"
print #main, "down"
print #main, "north"
print #main, "go 400" ' up
print #main, "up"
print #main, "home;north; turn 270;go 12; turn 270"
print #main, "down;go 400" ' down
' ************ ********* ********* ****8
print #main, "up"
print #main, "home;turn 90"
print #main, "down"

print #main, "go 360"
print #main, "up"
print #main, "home;north"
print #main, "down"
print #main, "turn 90"
print #main, "go 360"
print #main, "up;home"
print #main, "north;go 20;turn 90"
print #main, "down"
print #main, "size 1" ' all other lines will be thin
rem to here thick lines (end) section
rem the next few lines draws graphing grid ************ ********* ********* ********* ********* ********* ********* ********* ********* *******8

for ldraw1 = 1 to 850 step 20
print #main, "place 1 "; ldraw1;"down; go 760"
next ldraw1

for ldraw2 = 1 to 890 step 5
print #main, "place ";ldraw2 ;" 1";"down;turn 90;go 870"
next ldraw2
end sub ' end drawing of main grid
rem
rem

rem coordinates for axis

axisvar = val(axis\$)
rem cone\$ = yintercept
yint = val(cone\$)

rem ************ ********* ********* ********* debug it is drawing the yintercept twice I thnk!

[xy]
rem ************ ********* ********* ********* ********* *** IMPORTANT ************ ********* ********* ********* ****

notice "x(1) =";product1
notice "x(2) =";product2

call graphicsuse

' all graphics done here with automatic counting
' graph axis of symmetry
print #main, "up;home;north; turn 270;go 335;turn 270;go 250;north;turn 90" ' 335 is where to start graphics from exteme left side <----------
cox = adraw1 ' equals the numerical value of the axis

rem draws AXIS OF SYMMETRY ************ ********* ********* ********* *****
a = (-1 * 16)
goacross = 0
while a < cox
if a <> cox then
goacross = goacross + 2
end if
if a = cox then
exit while
end if
a = a + .1
wend

goa = int(goacross)

print #main, "go ";goa

print #main,"down; color RED;north;down; go 500"

print #main, "up;turn 180;go 850" ' graphics pencil at very bottom of screen (y=0) coordinate 640 pixel
print #main, "up;turn 180" ' draw up vertex point
rem draws VERTEX ************ ********* ********* *******
goup = 0
d = (-1 * 20) ' = -20
while d < ver
if d <> ver then
goup = goup + 2 ' go up 3 pixels
end if
if d = ver then
exit while ' if equal to vertex exit + draw it
end if
d = d + .1
wend
gp = int(goup) + 200
print #main, "go ";gp
print #main, "down;color BLUE"
print #main, "circle 5"
print #main, "posxy cx cy"

rem graph yintercept ************ **
rem ************ ********* ********* ** draw yintercept ************ ********* ****
rem cone\$ = yintercept
yint = val(cone\$)
z = (-1 * 20)
goy = 0
print #main, "up"
print #main, "home;north; turn 270;go 11;turn 270;go 400;turn 180"
while z < yint ' graph yintercept
if z <> yint then
goy = goy + 2
end if
if z = yint then
exit while
end if
z = z + .1
wend
print #main, "go ";goy
print #main, "down;circle 5"
print #main, "posxy yintx yinty"
rem get first sum (x) named product1 positive number ************ ********* ********* ******

print #main, "up;home;north; turn 270;go 11;up;turn 180"
prodacross1 = 0
e = 0
while e < product1
if e <> product1 then
prodacross1 = prodacross1 + 2
end if
if e = product1 then
exit while
end if
e = e + .1
wend
pr1 = int(prodacross1)
' for bigy and bigy2

print #main, "up;go ";pr1
print #main, "posxy bigyx bigyy"
print #main, "posxy bx by"
print #main, "down;circle 5"
' positive virtual x
print #main, "up;home;north; turn 270;go 11;up"
rem
f = 0
while f > product2
if f <> product2 then
goback = goback + 2
end if
if f = product2 then
exit while
end if
f = f - .1
wend
pr2 = int(goback)
print #main, "up;go ";pr2

print #main, "down;circle 5"
print #main, "posxy prod2x prod2y"
' for bigy and bigy2
print #main, "posxy bigyx2 bigyy2"
if havetoreverse = 8888 then goto [reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north"
g = 0
while g < bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g + .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy ax ay"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north"
h = 0
while h < bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h + .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy btwox btwoy"

rem ************ ********* ********* ********* ********* ********* ********* connect points ************ ********* ********* *******
rem ************ ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* *********

print #main, "place ";ax; " ";ay ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";yintx; " ";yinty ' yintercept point
print #main, "goto ";cx; " ";cy
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";btwox;" "; btwoy
print #main, "FLUSH"
wait
[reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north;turn 180"
g = 0
while g > bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g - .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy vx vy"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north;turn 180"
h = 0
while h > bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h - .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy gpx gpy"
rem ********** connect all points
print #main, "place ";vx; " ";vy ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";cx; " ";cy ' vertex
print #main, "goto ";yintx; " ";yinty
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";gpx;" "; gpy
print #main, "FLUSH"
wait
[gprint]
printerdialog

' print #main, "print vga" 'will scale up 600 wide image to full page
print #main, "print svga" 'will scale up 800 wide image to full page
' print #main, "print xga" 'will scale up 1024 wide image to full page

wait
[quit]
close #mwin
end
wait
[quit2]
close #main
end
[quit3]
close #mwin
END

[Non-text portions of this message have been removed]
• Well I am pretty new to graphics.  I just studied what Carl has the examples on LB website.  The text has to be enetered exactly for y=mx+b say: enter:
Message 3 of 5 , Apr 4, 2010
Well I am pretty new to graphics.  I just studied what Carl has the examples on LB website.
The text has to be enetered exactly for y=mx+b say: enter: y=3x+4 and it plots.
For y=ax^2+bx+c you have to enter say:y=2x^2+10x-7 and it can do negative parabolas such as y=-4x^2+20x+10.  I used a step statement of .1 to move the graphics.  You can write me I am in USA,
Marc

--- On Sun, 4/4/10, RipSaw <rij4360@...> wrote:

From: RipSaw <rij4360@...>
Subject: Re: [libertybasic] re:plotting points
To: libertybasic@yahoogroups.com
Date: Sunday, April 4, 2010, 9:54 AM

Marc where r u?  Here USA PA !  I got qs - jes I got qs!
Im trying to digest example earlier.   Is there anyone in USA - that can help me w graphics?
Say telephone? Kurt

____________ _________ _________ __
From: Marc <mrossi8888@yahoo. com>
To: libertybasic@ yahoogroups. com
Sent: Sun, April 4, 2010 9:25:02 AM
Subject: [libertybasic] re:plotting points

I wrote this to plot lines or parabolas. It is easy to follow if you can use it.
Marc
NOMAINWIN

global pressedq
global st44\$
global axminus
global axplus

WindowWidth = 250
WindowHeight = 250
button #mwin, "y=mx+b", [linear1], LR, 170, 10
button #mwin, "y=ax^2+bx+c" , [quadratic], LR, 90, 10
UpperLeftX = int(( DisplayWidth - WindowWidth ) / 2)
UpperLeftY = int(( DisplayHeight - WindowHeight ) / 2)
open "Graphing V 1.01" for Window_nf as #mwin

print #mwin, "trapclose [quit3]"

wait
prompt "Enter quadratic equation in form y=ax^2+bx+c" ;st44\$
pressedq = 99

close #mwin
if pressedq = 99 goto [quad44]

wait
Notice "QUADv1.01 ";chr\$(13);" By m f r 2010"

wait

[linear1]

ystringtouse1\$ = getinputin\$( string22\$ )

notice ystringtouse1\$

goto [c]

function getinputin\$( string11\$ )
PROMPT "Enter equation as y=rise/runx+ b:";st1\$
getinputin\$ = st1\$
end function

[c]
rem
call enterstring1\$ ystringtouse1\$ , stringtouse1\$ ,stringtouse2\$ ,stringtouse3\$ , stringtouse4\$
rem
close #mwin
call graphicsuse

print #main, "trapclose [quit2]"
print #main, "up;home;north; turn 270;go 10;north;turn 180;go 10;north"
' graph yintercept

yi = val(stringtouse4\$ ) ' stringtouse4\$ is the yintercept
y = (-1 * 1) ' compiler negation
while y < yi
if y <> yi then
gup = gup + 2
end if
if y = yi then
exit while
end if
y = y + .1
wend
print #main, "up;go ";gup
print #main, "down;color BLUE;circle 5"
print #main, "posxy yintx1 yinty1" ' keep posistion of the first point (yint)and go from here
print #main, "up"
rem graph the rise negative or positive
rise = val(stringtouse1\$ )
falserise = abs(rise)
t = 0
if rise < 0 then
while t < falserise ' rise is negative
if t <> rise then
negpos = negpos + 2
end if
if t = rise then
exit while
end if
t = t + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the second point(rise) and go from here
print #main, "north;turn 180;go ";negpos

end if
u = 0
if rise > 0 then
while u < rise
if u <> rise then
pospos = pospos + 2
end if
if u = rise then
exit while
end if
u = u + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the third point(run) and go from here
print #main, "north;go ";pospos

end if
' graph run point
run12 = val(stringtouse2\$ )
v = 0
while v < run12
if v <> run12 then
gorun = gorun + 2
end if
if v = run12 then
exit while
end if
v = v + .1
wend
print #main, "up;north;turn 90;go ";gorun
print #main, "down;circle 5;up"
print #main, "posxy runx2 runy2" ' keep posistion of the third point(run) and go from here
print #main, "down"
print #main, "place ";yintx1; " ";yinty1
print #main, "goto "; runx2; " ";runy2
print #main, "up"
rem ************ *start
if rise < 0 then ' this is negative rise going DOWN on the third point
print #main, "place ";runx2; " ";runy2
print #main, "north;turn 180"
while r < falserise
if falserise <> r then
goagain = goagain + 2
end if
if falserise = r then
exit while
end if
r = r + .1
wend
print #main, "go ";goagain
' this is the virtual DOWN
print #main, "up"

call gotofinalpoint run12

print #main, "posxy vx2 vy2"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";vx2; " ";vy2
end if
' everthing above this line is ok ************ ********* ********* ********* ********* ********* ********* ********* *****

if rise > 0 then ' third point pos rise
rem ************ ********* ********* ****last

print #main, "north" ' this is the rise of positive number UP on the third point
while e < rise
if rise <> e then
goagainlast = goagainlast + 2
end if
if rise = e then
exit while
end if
e = e + .1
wend
print #main, "go ";goagainlast
print #main, "up"
call gotofinalpoint run12
print #main, "posxy lastx lasty"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";lastx; " ";lasty
print #main, "FLUSH"
end if

wait

sub gotofinalpoint therise ' this sub is the run over to the right
print #main, "north;turn 90"
w = 0
while w < therise
if w <> therise then
go = go + 2
end if
if w = therise then
exit while
end if
w = w + .1
wend
print #main, "go ";go
print #main,"down; circle 5"

end sub

wait

wait

rem
sub enterstring1\$ ystring\$, byref st1\$,byref st2\$,byref st3\$,byref st4\$
rem
rem get rise
a = instr(ystring\$ ,"=")
c = instr(ystring\$ ,"/")
d = instr(ystring\$ ,"x")
e = instr(ystring\$ , "+")
f = instr(ystring\$ , "-")

rem y=123/34x-5
b = a + 1
st1\$ = mid\$(ystring\$ ,b,c-b) ' from = sign to / sign
rem get run
st2\$ = mid\$(ystring\$ ,c+1 , (d-c)-1) ' from / sign to "x"

get4\$ = mid\$(ystring\$ , 4,7)
negy = instr(get4\$, "-")
if negy > 0 then
st3\$ = "-" ' sign of yintercept
end if
if negy = 0 then
st3\$ = "+"
end if
st4\$ = mid\$(ystring\$ , d + 1,3)
end sub

wait

' rem start quadratic equation solving

call getquadratic\$ st44\$, aone\$, bone\$, cone\$

call getsign\$ aone\$, bone\$, cone\$,sign1\$ , sign2\$, sign3\$
rem assign global variables to use in graphics
rem if x is neg use else skip
if mid\$(aone\$,1, 1) = "-" then ' if it is a negative quadratic equation the next lines (turn the signs)
havetoreverse = 8888
turnpos1 = val(aone\$)
turnpos2 = val(bone\$)
turnpos3 = val(cone\$)
x1 = turnpos1 * -1
x2 = turnpos2 * -1
x3 = turnpos3 * -1
newaone\$ = str\$(x1)
newbone\$ = str\$(x2)
newcone\$ = str\$(x3)

aone\$ = newaone\$
bone\$ = newbone\$
cone\$ = newcone\$
end if
rem

call solvequadratic\$ aone\$, bone\$, cone\$,product1, product2

rem ************ ********* ****
gprod1 = product1
gprod2 = product2
rem ************ ****what product is larger?smaller? ************ ****
getmax = minmax(gprod1, gprod2,sm,bg)
rem
axplus = bg + 1
axminus = sm - 1
rem ************ ********* ******
if havetoreverse = 8888 then
call turnagain\$, aone\$, bone\$, cone\$
end if

rem ****
bigy = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axplus)
rem ************ ********* ********* ******
bigy2 = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axminus)
rem ************ ********* ********* ******

call getcoordinates\$ aone\$, bone\$, cone\$, axis\$, vertex\$
ver = val(vertex\$)
' ************ ********* ********* ********* ********* ********* ********* ********* *******

goto [xy]

sub getquadratic\$ st444\$,byref aa1\$,byref bb1\$,byref cc1\$
rem y=2x^2+45x+7
rem get a
numgeta = instr(st444\$ , "x")
aa1\$ = mid\$(st444\$, 3,numgeta- 3) ' get a (first number)
rem use a string to cut main string into a short string so as to locate position further in the string as not to get duplicate x
numlook = numgeta + 3
rem y=3x^2+45x+4
shortstring1\$ = mid\$(st444\$, numlook, 11)
findanotherx = instr(shortstring1\$ , "x")
bb1\$ = mid\$(shortstring1\$ , 1,findanotherx -1 )
moveaheadstring1\$ = mid\$(shortstring1\$ , findanotherx + 1, 8)
gets1\$ = mid\$(aa1\$,1, 1)
if gets1\$ <> "-" then
s1\$ = "+"
newa1\$ = s1\$+aa1\$
aa1\$ = ""
aa1\$ = newa1\$
end if
end sub

sub getsign\$ byref a1\$, byref b1\$, byref c1\$,byref s1\$, byref s2\$,byref s3\$

s1\$ = left\$(a1\$,1)
s2\$ = left\$(b1\$, 1)
s3\$ = left\$(c1\$, 1)
end sub

sub solvequadratic\$ byref term1\$,byref term2\$,byref term3\$,byref p1,byref p2

a1 = val(term1\$) ' a
b2 = val(term2\$) ' b
c3 = val(term3\$) ' c

rem -b +/- sqr((b^2 (- 4ac))) / 2a
x = (b2 * -1)
x2= sqr((b2^2)+( -4*a1*c3) )
p1 = (x + x2) / (2 * a1)
p2 = (x - x2) / (2 * a1)
end sub

sub getcoordinates\$ byref a2\$,byref b2\$,byref c2\$, byref axisofsymmetry\$ , byref vertexpoint\$
a2 = val(a2\$)
b2 = val(b2\$)
c2 = val(c2\$)

axisofsymmetry1 = (-1*b2)/(2*a2)
vertexpoint1 = ((4*a2*c2) - (b2^2))/ (4*a2)
axisofsymmetry\$ = str\$(axisofsymmetry 1)
vertexpoint\$ = str\$(vertexpoint1)
end sub

rem function to get y values replacing X with different variables to graph

function y(byref a\$, byref b\$,byref c\$,byref s1\$,byref s2\$,byref s3\$,byref x)

firstterm = val(a\$)
secondterm = val(b\$)
thirdterm = val(c\$)
power1 = x^2
atimespower1 = firstterm * power1
t1 = atimespower1
t2 = secondterm * x
if s2\$ = "-" then
common1 = t1 - t2
end if
if s2\$ = "+" then
common1 = t1 + t2 ' first and second term done
end if
if s3\$ = "-" then
common2 = common1 + thirdterm
y=common2
end if
if s3\$ = "+" then
common2 = common1 + thirdterm
y = common2
end if
end function

function minmax(byref vala, byref valb, byref small, byref big)
if vala > valb then
big = vala
small = valb
end if
if valb > vala then
big = valb
small = vala
end if
minmax = big
end function

sub turnagain\$ byref ae\$,byref be\$, byref ce\$
turn1 = val(ae\$)
turn2 = val(be\$)
turn3 = val(ce\$)

toturn1 = turn1 * -1
toturn2 = turn2 * -1
toturn3 = turn3 * -1

ae\$ = str\$(toturn1)
be\$ = str\$(toturn2)
ce\$ = str\$(toturn3)
end sub

sub graphicsuse ' drawing of main grid
WindowHeight = 700
WindowWidth = 700
UpperLeftX=Int( (DisplayWidth- WindowWidth) /2) 'This line and the next center the window
UpperLeftY=Int( (DisplayHeight- WindowHeight) /2)

Menu #main , "&Print" ,"&Print Graph",[gprint]
open "Graphing" for graphics_nf_ nsb as #main
rem the next section draws main grid lines (Thick)
print #main, "place 1 13";"down"
print #main, "\ ";st44\$
'print #main
print #main, "up"
print #main, "size 5"
print #main,"Home; turn 270;go 12"
print #main, "down"
print #main, "north"
print #main, "go 400" ' up
print #main, "up"
print #main, "home;north; turn 270;go 12; turn 270"
print #main, "down;go 400" ' down
' ************ ********* ********* ****8
print #main, "up"
print #main, "home;turn 90"
print #main, "down"

print #main, "go 360"
print #main, "up"
print #main, "home;north"
print #main, "down"
print #main, "turn 90"
print #main, "go 360"
print #main, "up;home"
print #main, "north;go 20;turn 90"
print #main, "down"
print #main, "size 1" ' all other lines will be thin
rem to here thick lines (end) section
rem the next few lines draws graphing grid ************ ********* ********* ********* ********* ********* ********* ********* ********* *******8

for ldraw1 = 1 to 850 step 20
print #main, "place 1 "; ldraw1;"down; go 760"
next ldraw1

for ldraw2 = 1 to 890 step 5
print #main, "place ";ldraw2 ;" 1";"down;turn 90;go 870"
next ldraw2
end sub ' end drawing of main grid
rem
rem

rem coordinates for axis

axisvar = val(axis\$)
rem cone\$ = yintercept
yint = val(cone\$)

rem ************ ********* ********* ********* debug it is drawing the yintercept twice I thnk!

[xy]
rem ************ ********* ********* ********* ********* *** IMPORTANT ************ ********* ********* ********* ****

notice "x(1) =";product1
notice "x(2) =";product2

call graphicsuse

' all graphics done here with automatic counting
' graph axis of symmetry
print #main, "up;home;north; turn 270;go 335;turn 270;go 250;north;turn 90" ' 335 is where to start graphics from exteme left side <----------
cox = adraw1 ' equals the numerical value of the axis

rem draws AXIS OF SYMMETRY ************ ********* ********* ********* *****
a = (-1 * 16)
goacross = 0
while a < cox
if a <> cox then
goacross = goacross + 2
end if
if a = cox then
exit while
end if
a = a + .1
wend

goa = int(goacross)

print #main, "go ";goa

print #main,"down; color RED;north;down; go 500"

print #main, "up;turn 180;go 850" ' graphics pencil at very bottom of screen (y=0) coordinate 640 pixel
print #main, "up;turn 180" ' draw up vertex point
rem draws VERTEX ************ ********* ********* *******
goup = 0
d = (-1 * 20) ' = -20
while d < ver
if d <> ver then
goup = goup + 2 ' go up 3 pixels
end if
if d = ver then
exit while ' if equal to vertex exit + draw it
end if
d = d + .1
wend
gp = int(goup) + 200
print #main, "go ";gp
print #main, "down;color BLUE"
print #main, "circle 5"
print #main, "posxy cx cy"

rem graph yintercept ************ **
rem ************ ********* ********* ** draw yintercept ************ ********* ****
rem cone\$ = yintercept
yint = val(cone\$)
z = (-1 * 20)
goy = 0
print #main, "up"
print #main, "home;north; turn 270;go 11;turn 270;go 400;turn 180"
while z < yint ' graph yintercept
if z <> yint then
goy = goy + 2
end if
if z = yint then
exit while
end if
z = z + .1
wend
print #main, "go ";goy
print #main, "down;circle 5"
print #main, "posxy yintx yinty"
rem get first sum (x) named product1 positive number ************ ********* ********* ******

print #main, "up;home;north; turn 270;go 11;up;turn 180"
prodacross1 = 0
e = 0
while e < product1
if e <> product1 then
prodacross1 = prodacross1 + 2
end if
if e = product1 then
exit while
end if
e = e + .1
wend
pr1 = int(prodacross1)
' for bigy and bigy2

print #main, "up;go ";pr1
print #main, "posxy bigyx bigyy"
print #main, "posxy bx by"
print #main, "down;circle 5"
' positive virtual x
print #main, "up;home;north; turn 270;go 11;up"
rem
f = 0
while f > product2
if f <> product2 then
goback = goback + 2
end if
if f = product2 then
exit while
end if
f = f - .1
wend
pr2 = int(goback)
print #main, "up;go ";pr2

print #main, "down;circle 5"
print #main, "posxy prod2x prod2y"
' for bigy and bigy2
print #main, "posxy bigyx2 bigyy2"
if havetoreverse = 8888 then goto [reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north"
g = 0
while g < bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g + .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy ax ay"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north"
h = 0
while h < bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h + .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy btwox btwoy"

rem ************ ********* ********* ********* ********* ********* ********* connect points ************ ********* ********* *******
rem ************ ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* *********

print #main, "place ";ax; " ";ay ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";yintx; " ";yinty ' yintercept point
print #main, "goto ";cx; " ";cy
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";btwox;" "; btwoy
print #main, "FLUSH"
wait
[reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north;turn 180"
g = 0
while g > bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g - .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy vx vy"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north;turn 180"
h = 0
while h > bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h - .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy gpx gpy"
rem ********** connect all points
print #main, "place ";vx; " ";vy ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";cx; " ";cy ' vertex
print #main, "goto ";yintx; " ";yinty
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";gpx;" "; gpy
print #main, "FLUSH"
wait
[gprint]
printerdialog

' print #main, "print vga" 'will scale up 600 wide image to full page
print #main, "print svga" 'will scale up 800 wide image to full page
' print #main, "print xga" 'will scale up 1024 wide image to full page

wait
[quit]
close #mwin
end
wait
[quit2]
close #main
end
[quit3]
close #mwin
END

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
• Thank u.   My HP48gx - has plot routines built in I just wanna cry. I get so frustrated. ________________________________ From: Marc Rossi
Message 4 of 5 , Apr 4, 2010
Thank u.   My HP48gx - has plot routines built in
I just wanna cry. I get so frustrated.

________________________________
From: Marc Rossi <mrossi8888@...>
To: libertybasic@yahoogroups.com
Sent: Sun, April 4, 2010 10:00:08 AM
Subject: Re: [libertybasic] re:plotting points

Well I am pretty new to graphics.  I just studied what Carl has the examples on LB website.
The text has to be enetered exactly for y=mx+b say: enter: y=3x+4 and it plots.
For y=ax^2+bx+c you have to enter say:y=2x^2+10x- 7 and it can do negative parabolas such as y=-4x^2+20x+ 10.  I used a step statement of .1 to move the graphics.  You can write me I am in USA,
Marc

--- On Sun, 4/4/10, RipSaw <rij4360@yahoo. com> wrote:

From: RipSaw <rij4360@yahoo. com>
Subject: Re: [libertybasic] re:plotting points
To: libertybasic@ yahoogroups. com
Date: Sunday, April 4, 2010, 9:54 AM

Marc where r u?  Here USA PA !  I got qs - jes I got qs!
Im trying to digest example earlier.   Is there anyone in USA - that can help me w graphics?
Say telephone? Kurt

____________ _________ _________ __
From: Marc <mrossi8888@ yahoo. com>
To: libertybasic@ yahoogroups. com
Sent: Sun, April 4, 2010 9:25:02 AM
Subject: [libertybasic] re:plotting points

I wrote this to plot lines or parabolas. It is easy to follow if you can use it.
Marc
NOMAINWIN

global pressedq
global st44\$
global axminus
global axplus

WindowWidth = 250
WindowHeight = 250
button #mwin, "y=mx+b", [linear1], LR, 170, 10
button #mwin, "y=ax^2+bx+c" , [quadratic], LR, 90, 10
UpperLeftX = int(( DisplayWidth - WindowWidth ) / 2)
UpperLeftY = int(( DisplayHeight - WindowHeight ) / 2)
open "Graphing V 1.01" for Window_nf as #mwin

print #mwin, "trapclose [quit3]"

wait
prompt "Enter quadratic equation in form y=ax^2+bx+c" ;st44\$
pressedq = 99

close #mwin
if pressedq = 99 goto [quad44]

wait
Notice "QUADv1.01 ";chr\$(13);" By m f r 2010"

wait

[linear1]

ystringtouse1\$ = getinputin\$( string22\$ )

notice ystringtouse1\$

goto [c]

function getinputin\$( string11\$ )
PROMPT "Enter equation as y=rise/runx+ b:";st1\$
getinputin\$ = st1\$
end function

[c]
rem
call enterstring1\$ ystringtouse1\$ , stringtouse1\$ ,stringtouse2\$ ,stringtouse3\$ , stringtouse4\$
rem
close #mwin
call graphicsuse

print #main, "trapclose [quit2]"
print #main, "up;home;north; turn 270;go 10;north;turn 180;go 10;north"
' graph yintercept

yi = val(stringtouse4\$ ) ' stringtouse4\$ is the yintercept
y = (-1 * 1) ' compiler negation
while y < yi
if y <> yi then
gup = gup + 2
end if
if y = yi then
exit while
end if
y = y + .1
wend
print #main, "up;go ";gup
print #main, "down;color BLUE;circle 5"
print #main, "posxy yintx1 yinty1" ' keep posistion of the first point (yint)and go from here
print #main, "up"
rem graph the rise negative or positive
rise = val(stringtouse1\$ )
falserise = abs(rise)
t = 0
if rise < 0 then
while t < falserise ' rise is negative
if t <> rise then
negpos = negpos + 2
end if
if t = rise then
exit while
end if
t = t + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the second point(rise) and go from here
print #main, "north;turn 180;go ";negpos

end if
u = 0
if rise > 0 then
while u < rise
if u <> rise then
pospos = pospos + 2
end if
if u = rise then
exit while
end if
u = u + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the third point(run) and go from here
print #main, "north;go ";pospos

end if
' graph run point
run12 = val(stringtouse2\$ )
v = 0
while v < run12
if v <> run12 then
gorun = gorun + 2
end if
if v = run12 then
exit while
end if
v = v + .1
wend
print #main, "up;north;turn 90;go ";gorun
print #main, "down;circle 5;up"
print #main, "posxy runx2 runy2" ' keep posistion of the third point(run) and go from here
print #main, "down"
print #main, "place ";yintx1; " ";yinty1
print #main, "goto "; runx2; " ";runy2
print #main, "up"
rem ************ *start
if rise < 0 then ' this is negative rise going DOWN on the third point
print #main, "place ";runx2; " ";runy2
print #main, "north;turn 180"
while r < falserise
if falserise <> r then
goagain = goagain + 2
end if
if falserise = r then
exit while
end if
r = r + .1
wend
print #main, "go ";goagain
' this is the virtual DOWN
print #main, "up"

call gotofinalpoint run12

print #main, "posxy vx2 vy2"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";vx2; " ";vy2
end if
' everthing above this line is ok ************ ********* ********* ********* ********* ********* ********* ********* *****

if rise > 0 then ' third point pos rise
rem ************ ********* ********* ****last

print #main, "north" ' this is the rise of positive number UP on the third point
while e < rise
if rise <> e then
goagainlast = goagainlast + 2
end if
if rise = e then
exit while
end if
e = e + .1
wend
print #main, "go ";goagainlast
print #main, "up"
call gotofinalpoint run12
print #main, "posxy lastx lasty"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";lastx; " ";lasty
print #main, "FLUSH"
end if

wait

sub gotofinalpoint therise ' this sub is the run over to the right
print #main, "north;turn 90"
w = 0
while w < therise
if w <> therise then
go = go + 2
end if
if w = therise then
exit while
end if
w = w + .1
wend
print #main, "go ";go
print #main,"down; circle 5"

end sub

wait

wait

rem
sub enterstring1\$ ystring\$, byref st1\$,byref st2\$,byref st3\$,byref st4\$
rem
rem get rise
a = instr(ystring\$ ,"=")
c = instr(ystring\$ ,"/")
d = instr(ystring\$ ,"x")
e = instr(ystring\$ , "+")
f = instr(ystring\$ , "-")

rem y=123/34x-5
b = a + 1
st1\$ = mid\$(ystring\$ ,b,c-b) ' from = sign to / sign
rem get run
st2\$ = mid\$(ystring\$ ,c+1 , (d-c)-1) ' from / sign to "x"

get4\$ = mid\$(ystring\$ , 4,7)
negy = instr(get4\$, "-")
if negy > 0 then
st3\$ = "-" ' sign of yintercept
end if
if negy = 0 then
st3\$ = "+"
end if
st4\$ = mid\$(ystring\$ , d + 1,3)
end sub

wait

' rem start quadratic equation solving

call getquadratic\$ st44\$, aone\$, bone\$, cone\$

call getsign\$ aone\$, bone\$, cone\$,sign1\$ , sign2\$, sign3\$
rem assign global variables to use in graphics
rem if x is neg use else skip
if mid\$(aone\$,1, 1) = "-" then ' if it is a negative quadratic equation the next lines (turn the signs)
havetoreverse = 8888
turnpos1 = val(aone\$)
turnpos2 = val(bone\$)
turnpos3 = val(cone\$)
x1 = turnpos1 * -1
x2 = turnpos2 * -1
x3 = turnpos3 * -1
newaone\$ = str\$(x1)
newbone\$ = str\$(x2)
newcone\$ = str\$(x3)

aone\$ = newaone\$
bone\$ = newbone\$
cone\$ = newcone\$
end if
rem

call solvequadratic\$ aone\$, bone\$, cone\$,product1, product2

rem ************ ********* ****
gprod1 = product1
gprod2 = product2
rem ************ ****what product is larger?smaller? ************ ****
getmax = minmax(gprod1, gprod2,sm,bg)
rem
axplus = bg + 1
axminus = sm - 1
rem ************ ********* ******
if havetoreverse = 8888 then
call turnagain\$, aone\$, bone\$, cone\$
end if

rem ****
bigy = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axplus)
rem ************ ********* ********* ******
bigy2 = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axminus)
rem ************ ********* ********* ******

call getcoordinates\$ aone\$, bone\$, cone\$, axis\$, vertex\$
ver = val(vertex\$)
' ************ ********* ********* ********* ********* ********* ********* ********* *******

goto [xy]

sub getquadratic\$ st444\$,byref aa1\$,byref bb1\$,byref cc1\$
rem y=2x^2+45x+7
rem get a
numgeta = instr(st444\$ , "x")
aa1\$ = mid\$(st444\$, 3,numgeta- 3) ' get a (first number)
rem use a string to cut main string into a short string so as to locate position further in the string as not to get duplicate x
numlook = numgeta + 3
rem y=3x^2+45x+4
shortstring1\$ = mid\$(st444\$, numlook, 11)
findanotherx = instr(shortstring1\$ , "x")
bb1\$ = mid\$(shortstring1\$ , 1,findanotherx -1 )
moveaheadstring1\$ = mid\$(shortstring1\$ , findanotherx + 1, 8)
gets1\$ = mid\$(aa1\$,1, 1)
if gets1\$ <> "-" then
s1\$ = "+"
newa1\$ = s1\$+aa1\$
aa1\$ = ""
aa1\$ = newa1\$
end if
end sub

sub getsign\$ byref a1\$, byref b1\$, byref c1\$,byref s1\$, byref s2\$,byref s3\$

s1\$ = left\$(a1\$,1)
s2\$ = left\$(b1\$, 1)
s3\$ = left\$(c1\$, 1)
end sub

sub solvequadratic\$ byref term1\$,byref term2\$,byref term3\$,byref p1,byref p2

a1 = val(term1\$) ' a
b2 = val(term2\$) ' b
c3 = val(term3\$) ' c

rem -b +/- sqr((b^2 (- 4ac))) / 2a
x = (b2 * -1)
x2= sqr((b2^2)+( -4*a1*c3) )
p1 = (x + x2) / (2 * a1)
p2 = (x - x2) / (2 * a1)
end sub

sub getcoordinates\$ byref a2\$,byref b2\$,byref c2\$, byref axisofsymmetry\$ , byref vertexpoint\$
a2 = val(a2\$)
b2 = val(b2\$)
c2 = val(c2\$)

axisofsymmetry1 = (-1*b2)/(2*a2)
vertexpoint1 = ((4*a2*c2) - (b2^2))/ (4*a2)
axisofsymmetry\$ = str\$(axisofsymmetry 1)
vertexpoint\$ = str\$(vertexpoint1)
end sub

rem function to get y values replacing X with different variables to graph

function y(byref a\$, byref b\$,byref c\$,byref s1\$,byref s2\$,byref s3\$,byref x)

firstterm = val(a\$)
secondterm = val(b\$)
thirdterm = val(c\$)
power1 = x^2
atimespower1 = firstterm * power1
t1 = atimespower1
t2 = secondterm * x
if s2\$ = "-" then
common1 = t1 - t2
end if
if s2\$ = "+" then
common1 = t1 + t2 ' first and second term done
end if
if s3\$ = "-" then
common2 = common1 + thirdterm
y=common2
end if
if s3\$ = "+" then
common2 = common1 + thirdterm
y = common2
end if
end function

function minmax(byref vala, byref valb, byref small, byref big)
if vala > valb then
big = vala
small = valb
end if
if valb > vala then
big = valb
small = vala
end if
minmax = big
end function

sub turnagain\$ byref ae\$,byref be\$, byref ce\$
turn1 = val(ae\$)
turn2 = val(be\$)
turn3 = val(ce\$)

toturn1 = turn1 * -1
toturn2 = turn2 * -1
toturn3 = turn3 * -1

ae\$ = str\$(toturn1)
be\$ = str\$(toturn2)
ce\$ = str\$(toturn3)
end sub

sub graphicsuse ' drawing of main grid
WindowHeight = 700
WindowWidth = 700
UpperLeftX=Int( (DisplayWidth- WindowWidth) /2) 'This line and the next center the window
UpperLeftY=Int( (DisplayHeight- WindowHeight) /2)

Menu #main , "&Print" ,"&Print Graph",[gprint]
open "Graphing" for graphics_nf_ nsb as #main
rem the next section draws main grid lines (Thick)
print #main, "place 1 13";"down"
print #main, "\ ";st44\$
'print #main
print #main, "up"
print #main, "size 5"
print #main,"Home; turn 270;go 12"
print #main, "down"
print #main, "north"
print #main, "go 400" ' up
print #main, "up"
print #main, "home;north; turn 270;go 12; turn 270"
print #main, "down;go 400" ' down
' ************ ********* ********* ****8
print #main, "up"
print #main, "home;turn 90"
print #main, "down"

print #main, "go 360"
print #main, "up"
print #main, "home;north"
print #main, "down"
print #main, "turn 90"
print #main, "go 360"
print #main, "up;home"
print #main, "north;go 20;turn 90"
print #main, "down"
print #main, "size 1" ' all other lines will be thin
rem to here thick lines (end) section
rem the next few lines draws graphing grid ************ ********* ********* ********* ********* ********* ********* ********* ********* *******8

for ldraw1 = 1 to 850 step 20
print #main, "place 1 "; ldraw1;"down; go 760"
next ldraw1

for ldraw2 = 1 to 890 step 5
print #main, "place ";ldraw2 ;" 1";"down;turn 90;go 870"
next ldraw2
end sub ' end drawing of main grid
rem
rem

rem coordinates for axis

axisvar = val(axis\$)
rem cone\$ = yintercept
yint = val(cone\$)

rem ************ ********* ********* ********* debug it is drawing the yintercept twice I thnk!

[xy]
rem ************ ********* ********* ********* ********* *** IMPORTANT ************ ********* ********* ********* ****

notice "x(1) =";product1
notice "x(2) =";product2

call graphicsuse

' all graphics done here with automatic counting
' graph axis of symmetry
print #main, "up;home;north; turn 270;go 335;turn 270;go 250;north;turn 90" ' 335 is where to start graphics from exteme left side <----------
cox = adraw1 ' equals the numerical value of the axis

rem draws AXIS OF SYMMETRY ************ ********* ********* ********* *****
a = (-1 * 16)
goacross = 0
while a < cox
if a <> cox then
goacross = goacross + 2
end if
if a = cox then
exit while
end if
a = a + .1
wend

goa = int(goacross)

print #main, "go ";goa

print #main,"down; color RED;north;down; go 500"

print #main, "up;turn 180;go 850" ' graphics pencil at very bottom of screen (y=0) coordinate 640 pixel
print #main, "up;turn 180" ' draw up vertex point
rem draws VERTEX ************ ********* ********* *******
goup = 0
d = (-1 * 20) ' = -20
while d < ver
if d <> ver then
goup = goup + 2 ' go up 3 pixels
end if
if d = ver then
exit while ' if equal to vertex exit + draw it
end if
d = d + .1
wend
gp = int(goup) + 200
print #main, "go ";gp
print #main, "down;color BLUE"
print #main, "circle 5"
print #main, "posxy cx cy"

rem graph yintercept ************ **
rem ************ ********* ********* ** draw yintercept ************ ********* ****
rem cone\$ = yintercept
yint = val(cone\$)
z = (-1 * 20)
goy = 0
print #main, "up"
print #main, "home;north; turn 270;go 11;turn 270;go 400;turn 180"
while z < yint ' graph yintercept
if z <> yint then
goy = goy + 2
end if
if z = yint then
exit while
end if
z = z + .1
wend
print #main, "go ";goy
print #main, "down;circle 5"
print #main, "posxy yintx yinty"
rem get first sum (x) named product1 positive number ************ ********* ********* ******

print #main, "up;home;north; turn 270;go 11;up;turn 180"
prodacross1 = 0
e = 0
while e < product1
if e <> product1 then
prodacross1 = prodacross1 + 2
end if
if e = product1 then
exit while
end if
e = e + .1
wend
pr1 = int(prodacross1)
' for bigy and bigy2

print #main, "up;go ";pr1
print #main, "posxy bigyx bigyy"
print #main, "posxy bx by"
print #main, "down;circle 5"
' positive virtual x
print #main, "up;home;north; turn 270;go 11;up"
rem
f = 0
while f > product2
if f <> product2 then
goback = goback + 2
end if
if f = product2 then
exit while
end if
f = f - .1
wend
pr2 = int(goback)
print #main, "up;go ";pr2

print #main, "down;circle 5"
print #main, "posxy prod2x prod2y"
' for bigy and bigy2
print #main, "posxy bigyx2 bigyy2"
if havetoreverse = 8888 then goto [reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north"
g = 0
while g < bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g + .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy ax ay"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north"
h = 0
while h < bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h + .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy btwox btwoy"

rem ************ ********* ********* ********* ********* ********* ********* connect points ************ ********* ********* *******
rem ************ ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* *********

print #main, "place ";ax; " ";ay ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";yintx; " ";yinty ' yintercept point
print #main, "goto ";cx; " ";cy
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";btwox;" "; btwoy
print #main, "FLUSH"
wait
[reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north;turn 180"
g = 0
while g > bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g - .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy vx vy"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north;turn 180"
h = 0
while h > bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h - .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy gpx gpy"
rem ********** connect all points
print #main, "place ";vx; " ";vy ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";cx; " ";cy ' vertex
print #main, "goto ";yintx; " ";yinty
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";gpx;" "; gpy
print #main, "FLUSH"
wait
[gprint]
printerdialog

' print #main, "print vga" 'will scale up 600 wide image to full page
print #main, "print svga" 'will scale up 800 wide image to full page
' print #main, "print xga" 'will scale up 1024 wide image to full page

wait
[quit]
close #mwin
end
wait
[quit2]
close #main
end
[quit3]
close #mwin
END

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
• I was at an Easter dinner so I couldn t get back to you till this morning.  I printed out all of (well alot) of the graphics routines and made a book to keep
Message 5 of 5 , Apr 5, 2010
I was at an Easter dinner so I couldn't get back to you till this morning.  I printed out all of (well alot) of the graphics routines and made a book to keep them in.  You can call if you want my number I will give it to you
Marc

--- On Sun, 4/4/10, RipSaw <rij4360@...> wrote:

From: RipSaw <rij4360@...>
Subject: Re: [libertybasic] re:plotting points
To: libertybasic@yahoogroups.com
Date: Sunday, April 4, 2010, 9:54 AM

Marc where r u?  Here USA PA !  I got qs - jes I got qs!
Im trying to digest example earlier.   Is there anyone in USA - that can help me w graphics?
Say telephone? Kurt

____________ _________ _________ __
From: Marc <mrossi8888@yahoo. com>
To: libertybasic@ yahoogroups. com
Sent: Sun, April 4, 2010 9:25:02 AM
Subject: [libertybasic] re:plotting points

I wrote this to plot lines or parabolas. It is easy to follow if you can use it.
Marc
NOMAINWIN

global pressedq
global st44\$
global axminus
global axplus

WindowWidth = 250
WindowHeight = 250
button #mwin, "y=mx+b", [linear1], LR, 170, 10
button #mwin, "y=ax^2+bx+c" , [quadratic], LR, 90, 10
UpperLeftX = int(( DisplayWidth - WindowWidth ) / 2)
UpperLeftY = int(( DisplayHeight - WindowHeight ) / 2)
open "Graphing V 1.01" for Window_nf as #mwin

print #mwin, "trapclose [quit3]"

wait
prompt "Enter quadratic equation in form y=ax^2+bx+c" ;st44\$
pressedq = 99

close #mwin
if pressedq = 99 goto [quad44]

wait
Notice "QUADv1.01 ";chr\$(13);" By m f r 2010"

wait

[linear1]

ystringtouse1\$ = getinputin\$( string22\$ )

notice ystringtouse1\$

goto [c]

function getinputin\$( string11\$ )
PROMPT "Enter equation as y=rise/runx+ b:";st1\$
getinputin\$ = st1\$
end function

[c]
rem
call enterstring1\$ ystringtouse1\$ , stringtouse1\$ ,stringtouse2\$ ,stringtouse3\$ , stringtouse4\$
rem
close #mwin
call graphicsuse

print #main, "trapclose [quit2]"
print #main, "up;home;north; turn 270;go 10;north;turn 180;go 10;north"
' graph yintercept

yi = val(stringtouse4\$ ) ' stringtouse4\$ is the yintercept
y = (-1 * 1) ' compiler negation
while y < yi
if y <> yi then
gup = gup + 2
end if
if y = yi then
exit while
end if
y = y + .1
wend
print #main, "up;go ";gup
print #main, "down;color BLUE;circle 5"
print #main, "posxy yintx1 yinty1" ' keep posistion of the first point (yint)and go from here
print #main, "up"
rem graph the rise negative or positive
rise = val(stringtouse1\$ )
falserise = abs(rise)
t = 0
if rise < 0 then
while t < falserise ' rise is negative
if t <> rise then
negpos = negpos + 2
end if
if t = rise then
exit while
end if
t = t + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the second point(rise) and go from here
print #main, "north;turn 180;go ";negpos

end if
u = 0
if rise > 0 then
while u < rise
if u <> rise then
pospos = pospos + 2
end if
if u = rise then
exit while
end if
u = u + .1
wend
print #main, "posxy risex1 risey1" ' keep posistion of the third point(run) and go from here
print #main, "north;go ";pospos

end if
' graph run point
run12 = val(stringtouse2\$ )
v = 0
while v < run12
if v <> run12 then
gorun = gorun + 2
end if
if v = run12 then
exit while
end if
v = v + .1
wend
print #main, "up;north;turn 90;go ";gorun
print #main, "down;circle 5;up"
print #main, "posxy runx2 runy2" ' keep posistion of the third point(run) and go from here
print #main, "down"
print #main, "place ";yintx1; " ";yinty1
print #main, "goto "; runx2; " ";runy2
print #main, "up"
rem ************ *start
if rise < 0 then ' this is negative rise going DOWN on the third point
print #main, "place ";runx2; " ";runy2
print #main, "north;turn 180"
while r < falserise
if falserise <> r then
goagain = goagain + 2
end if
if falserise = r then
exit while
end if
r = r + .1
wend
print #main, "go ";goagain
' this is the virtual DOWN
print #main, "up"

call gotofinalpoint run12

print #main, "posxy vx2 vy2"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";vx2; " ";vy2
end if
' everthing above this line is ok ************ ********* ********* ********* ********* ********* ********* ********* *****

if rise > 0 then ' third point pos rise
rem ************ ********* ********* ****last

print #main, "north" ' this is the rise of positive number UP on the third point
while e < rise
if rise <> e then
goagainlast = goagainlast + 2
end if
if rise = e then
exit while
end if
e = e + .1
wend
print #main, "go ";goagainlast
print #main, "up"
call gotofinalpoint run12
print #main, "posxy lastx lasty"
print #main, "place ";runx2; " ";runy2
print #main, "goto ";lastx; " ";lasty
print #main, "FLUSH"
end if

wait

sub gotofinalpoint therise ' this sub is the run over to the right
print #main, "north;turn 90"
w = 0
while w < therise
if w <> therise then
go = go + 2
end if
if w = therise then
exit while
end if
w = w + .1
wend
print #main, "go ";go
print #main,"down; circle 5"

end sub

wait

wait

rem
sub enterstring1\$ ystring\$, byref st1\$,byref st2\$,byref st3\$,byref st4\$
rem
rem get rise
a = instr(ystring\$ ,"=")
c = instr(ystring\$ ,"/")
d = instr(ystring\$ ,"x")
e = instr(ystring\$ , "+")
f = instr(ystring\$ , "-")

rem y=123/34x-5
b = a + 1
st1\$ = mid\$(ystring\$ ,b,c-b) ' from = sign to / sign
rem get run
st2\$ = mid\$(ystring\$ ,c+1 , (d-c)-1) ' from / sign to "x"

get4\$ = mid\$(ystring\$ , 4,7)
negy = instr(get4\$, "-")
if negy > 0 then
st3\$ = "-" ' sign of yintercept
end if
if negy = 0 then
st3\$ = "+"
end if
st4\$ = mid\$(ystring\$ , d + 1,3)
end sub

wait

' rem start quadratic equation solving

call getquadratic\$ st44\$, aone\$, bone\$, cone\$

call getsign\$ aone\$, bone\$, cone\$,sign1\$ , sign2\$, sign3\$
rem assign global variables to use in graphics
rem if x is neg use else skip
if mid\$(aone\$,1, 1) = "-" then ' if it is a negative quadratic equation the next lines (turn the signs)
havetoreverse = 8888
turnpos1 = val(aone\$)
turnpos2 = val(bone\$)
turnpos3 = val(cone\$)
x1 = turnpos1 * -1
x2 = turnpos2 * -1
x3 = turnpos3 * -1
newaone\$ = str\$(x1)
newbone\$ = str\$(x2)
newcone\$ = str\$(x3)

aone\$ = newaone\$
bone\$ = newbone\$
cone\$ = newcone\$
end if
rem

call solvequadratic\$ aone\$, bone\$, cone\$,product1, product2

rem ************ ********* ****
gprod1 = product1
gprod2 = product2
rem ************ ****what product is larger?smaller? ************ ****
getmax = minmax(gprod1, gprod2,sm,bg)
rem
axplus = bg + 1
axminus = sm - 1
rem ************ ********* ******
if havetoreverse = 8888 then
call turnagain\$, aone\$, bone\$, cone\$
end if

rem ****
bigy = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axplus)
rem ************ ********* ********* ******
bigy2 = y(aone\$, bone\$, cone\$, sign1\$, sign2\$, sign3\$,axminus)
rem ************ ********* ********* ******

call getcoordinates\$ aone\$, bone\$, cone\$, axis\$, vertex\$
ver = val(vertex\$)
' ************ ********* ********* ********* ********* ********* ********* ********* *******

goto [xy]

sub getquadratic\$ st444\$,byref aa1\$,byref bb1\$,byref cc1\$
rem y=2x^2+45x+7
rem get a
numgeta = instr(st444\$ , "x")
aa1\$ = mid\$(st444\$, 3,numgeta- 3) ' get a (first number)
rem use a string to cut main string into a short string so as to locate position further in the string as not to get duplicate x
numlook = numgeta + 3
rem y=3x^2+45x+4
shortstring1\$ = mid\$(st444\$, numlook, 11)
findanotherx = instr(shortstring1\$ , "x")
bb1\$ = mid\$(shortstring1\$ , 1,findanotherx -1 )
moveaheadstring1\$ = mid\$(shortstring1\$ , findanotherx + 1, 8)
gets1\$ = mid\$(aa1\$,1, 1)
if gets1\$ <> "-" then
s1\$ = "+"
newa1\$ = s1\$+aa1\$
aa1\$ = ""
aa1\$ = newa1\$
end if
end sub

sub getsign\$ byref a1\$, byref b1\$, byref c1\$,byref s1\$, byref s2\$,byref s3\$

s1\$ = left\$(a1\$,1)
s2\$ = left\$(b1\$, 1)
s3\$ = left\$(c1\$, 1)
end sub

sub solvequadratic\$ byref term1\$,byref term2\$,byref term3\$,byref p1,byref p2

a1 = val(term1\$) ' a
b2 = val(term2\$) ' b
c3 = val(term3\$) ' c

rem -b +/- sqr((b^2 (- 4ac))) / 2a
x = (b2 * -1)
x2= sqr((b2^2)+( -4*a1*c3) )
p1 = (x + x2) / (2 * a1)
p2 = (x - x2) / (2 * a1)
end sub

sub getcoordinates\$ byref a2\$,byref b2\$,byref c2\$, byref axisofsymmetry\$ , byref vertexpoint\$
a2 = val(a2\$)
b2 = val(b2\$)
c2 = val(c2\$)

axisofsymmetry1 = (-1*b2)/(2*a2)
vertexpoint1 = ((4*a2*c2) - (b2^2))/ (4*a2)
axisofsymmetry\$ = str\$(axisofsymmetry 1)
vertexpoint\$ = str\$(vertexpoint1)
end sub

rem function to get y values replacing X with different variables to graph

function y(byref a\$, byref b\$,byref c\$,byref s1\$,byref s2\$,byref s3\$,byref x)

firstterm = val(a\$)
secondterm = val(b\$)
thirdterm = val(c\$)
power1 = x^2
atimespower1 = firstterm * power1
t1 = atimespower1
t2 = secondterm * x
if s2\$ = "-" then
common1 = t1 - t2
end if
if s2\$ = "+" then
common1 = t1 + t2 ' first and second term done
end if
if s3\$ = "-" then
common2 = common1 + thirdterm
y=common2
end if
if s3\$ = "+" then
common2 = common1 + thirdterm
y = common2
end if
end function

function minmax(byref vala, byref valb, byref small, byref big)
if vala > valb then
big = vala
small = valb
end if
if valb > vala then
big = valb
small = vala
end if
minmax = big
end function

sub turnagain\$ byref ae\$,byref be\$, byref ce\$
turn1 = val(ae\$)
turn2 = val(be\$)
turn3 = val(ce\$)

toturn1 = turn1 * -1
toturn2 = turn2 * -1
toturn3 = turn3 * -1

ae\$ = str\$(toturn1)
be\$ = str\$(toturn2)
ce\$ = str\$(toturn3)
end sub

sub graphicsuse ' drawing of main grid
WindowHeight = 700
WindowWidth = 700
UpperLeftX=Int( (DisplayWidth- WindowWidth) /2) 'This line and the next center the window
UpperLeftY=Int( (DisplayHeight- WindowHeight) /2)

Menu #main , "&Print" ,"&Print Graph",[gprint]
open "Graphing" for graphics_nf_ nsb as #main
rem the next section draws main grid lines (Thick)
print #main, "place 1 13";"down"
print #main, "\ ";st44\$
'print #main
print #main, "up"
print #main, "size 5"
print #main,"Home; turn 270;go 12"
print #main, "down"
print #main, "north"
print #main, "go 400" ' up
print #main, "up"
print #main, "home;north; turn 270;go 12; turn 270"
print #main, "down;go 400" ' down
' ************ ********* ********* ****8
print #main, "up"
print #main, "home;turn 90"
print #main, "down"

print #main, "go 360"
print #main, "up"
print #main, "home;north"
print #main, "down"
print #main, "turn 90"
print #main, "go 360"
print #main, "up;home"
print #main, "north;go 20;turn 90"
print #main, "down"
print #main, "size 1" ' all other lines will be thin
rem to here thick lines (end) section
rem the next few lines draws graphing grid ************ ********* ********* ********* ********* ********* ********* ********* ********* *******8

for ldraw1 = 1 to 850 step 20
print #main, "place 1 "; ldraw1;"down; go 760"
next ldraw1

for ldraw2 = 1 to 890 step 5
print #main, "place ";ldraw2 ;" 1";"down;turn 90;go 870"
next ldraw2
end sub ' end drawing of main grid
rem
rem

rem coordinates for axis

axisvar = val(axis\$)
rem cone\$ = yintercept
yint = val(cone\$)

rem ************ ********* ********* ********* debug it is drawing the yintercept twice I thnk!

[xy]
rem ************ ********* ********* ********* ********* *** IMPORTANT ************ ********* ********* ********* ****

notice "x(1) =";product1
notice "x(2) =";product2

call graphicsuse

' all graphics done here with automatic counting
' graph axis of symmetry
print #main, "up;home;north; turn 270;go 335;turn 270;go 250;north;turn 90" ' 335 is where to start graphics from exteme left side <----------
cox = adraw1 ' equals the numerical value of the axis

rem draws AXIS OF SYMMETRY ************ ********* ********* ********* *****
a = (-1 * 16)
goacross = 0
while a < cox
if a <> cox then
goacross = goacross + 2
end if
if a = cox then
exit while
end if
a = a + .1
wend

goa = int(goacross)

print #main, "go ";goa

print #main,"down; color RED;north;down; go 500"

print #main, "up;turn 180;go 850" ' graphics pencil at very bottom of screen (y=0) coordinate 640 pixel
print #main, "up;turn 180" ' draw up vertex point
rem draws VERTEX ************ ********* ********* *******
goup = 0
d = (-1 * 20) ' = -20
while d < ver
if d <> ver then
goup = goup + 2 ' go up 3 pixels
end if
if d = ver then
exit while ' if equal to vertex exit + draw it
end if
d = d + .1
wend
gp = int(goup) + 200
print #main, "go ";gp
print #main, "down;color BLUE"
print #main, "circle 5"
print #main, "posxy cx cy"

rem graph yintercept ************ **
rem ************ ********* ********* ** draw yintercept ************ ********* ****
rem cone\$ = yintercept
yint = val(cone\$)
z = (-1 * 20)
goy = 0
print #main, "up"
print #main, "home;north; turn 270;go 11;turn 270;go 400;turn 180"
while z < yint ' graph yintercept
if z <> yint then
goy = goy + 2
end if
if z = yint then
exit while
end if
z = z + .1
wend
print #main, "go ";goy
print #main, "down;circle 5"
print #main, "posxy yintx yinty"
rem get first sum (x) named product1 positive number ************ ********* ********* ******

print #main, "up;home;north; turn 270;go 11;up;turn 180"
prodacross1 = 0
e = 0
while e < product1
if e <> product1 then
prodacross1 = prodacross1 + 2
end if
if e = product1 then
exit while
end if
e = e + .1
wend
pr1 = int(prodacross1)
' for bigy and bigy2

print #main, "up;go ";pr1
print #main, "posxy bigyx bigyy"
print #main, "posxy bx by"
print #main, "down;circle 5"
' positive virtual x
print #main, "up;home;north; turn 270;go 11;up"
rem
f = 0
while f > product2
if f <> product2 then
goback = goback + 2
end if
if f = product2 then
exit while
end if
f = f - .1
wend
pr2 = int(goback)
print #main, "up;go ";pr2

print #main, "down;circle 5"
print #main, "posxy prod2x prod2y"
' for bigy and bigy2
print #main, "posxy bigyx2 bigyy2"
if havetoreverse = 8888 then goto [reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north"
g = 0
while g < bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g + .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy ax ay"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north"
h = 0
while h < bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h + .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy btwox btwoy"

rem ************ ********* ********* ********* ********* ********* ********* connect points ************ ********* ********* *******
rem ************ ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* ********* *********

print #main, "place ";ax; " ";ay ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";yintx; " ";yinty ' yintercept point
print #main, "goto ";cx; " ";cy
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";btwox;" "; btwoy
print #main, "FLUSH"
wait
[reverse]

print #main, "place ";bigyx; " ";bigyy
print #main, "up;north;turn 180"
g = 0
while g > bigy
if g <> bigy then
goupbigy = goupbigy + 2
end if
if g = bigy then
exit while
end if
g = g - .1
wend
print #main, "up;go ";goupbigy
print #main, "down;circle 5"
print #main, "posxy vx vy"
rem get second sum (the negative ) and graph product2 ************ ********* ********* ********* *****
rem position at home North

rem draw virtual x coordinates as given by y function ************ ********* ******
rem bigy = positive
rem bigy2 = negative
rem bring pencil home

' negative virtual x
print #main, "place ";bigyx2; " ";bigyy2
print #main, "up;north;turn 180"
h = 0
while h > bigy2
if h <> bigy2 then
goupbigy2 = goupbigy2 + 2
end if
if h = bigy2 then
exit while
end if
h = h - .1
wend
print #main, "up;go ";goupbigy2
print #main, "down;circle 5"
print #main, "posxy gpx gpy"
rem ********** connect all points
print #main, "place ";vx; " ";vy ' connect all points ' virtual x
print #main, "down"
print #main, "goto ";bx; " ";by ' x product on right
print #main, "goto ";cx; " ";cy ' vertex
print #main, "goto ";yintx; " ";yinty
print #main, "goto ";prod2x ; " ";prod2y
print #main, "goto ";gpx;" "; gpy
print #main, "FLUSH"
wait
[gprint]
printerdialog

' print #main, "print vga" 'will scale up 600 wide image to full page
print #main, "print svga" 'will scale up 800 wide image to full page
' print #main, "print xga" 'will scale up 1024 wide image to full page

wait
[quit]
close #mwin
end
wait
[quit2]
close #main
end
[quit3]
close #mwin
END

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
Your message has been successfully submitted and would be delivered to recipients shortly.