Forums: Forum of Decimal BASIC (Thread #38157)

3D-graphs (2016-11-04 04:54 by BSpinoza #78951)

Is there a possibility or is it planned to make 3D-Graphics ?

Reply to #78951×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-04 08:51 by SHIRAISHI Kazuo #78952)

Transformation defined in Full BASIC can manipulate 3-D coordinates.
Samples\3DView.BAS, 3DView2.BAS, 3DView3.BAS, 3DView4.BAS, 3DViewRC are examples which use transformation matrices.
Reply to #78951

Reply to #78952×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-04 09:03 by SHIRAISHI Kazuo #78953)

On Full BASIC, we can draw graphics on a plane, and we can tarnsform it in the 3D space. We can view the 3D space in one direction, but we can move it.
Reply to #78951

Reply to #78953×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-04 15:43 by BSpinoza #78955)

Thank you Mr. Shiraishi for your prompt answers.
I think my question was not clearly formulated.
I thought about the drawing of 3D-functions with axes.


Reply to #78953

Reply to #78955×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-05 08:55 by SHIRAISHI Kazuo #78966)

Drawing a graph of a function is a matter of programming on Full BASIC.
Sample programs Lorenz.BAS and Lorenz_attractor.BAS might show some of such solutions.
Reply to #78955

Reply to #78966×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-05 18:50 by toml_12953 #78970)

[Reply To Message #78966]
> Drawing a graph of a function is a matter of programming on Full BASIC.
> Sample programs Lorenz.BAS and Lorenz_attractor.BAS might show some of such solutions.

How about an extension of BASIC to allow

PLOT x,y[,z]

where the z parameter is optional?

Tom L
Reply to #78966

Reply to #78970×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-07 16:08 by SHIRAISHI Kazuo #78990)

Within Full BASIC standard, the current transformation matrix can be obtained by a MAT-TRANSFORM statement.

EXTERNAL SUB PLOT(x,y,z)
DECLARE NUMERIC POINT(4)
DECLARE NUMERIC m(4,4)
MAT m=TRANSFORM
LET POINT(1)=x
LET POINT(2)=y
LET POINT(3)=z
LET POINT(4)=1
MAT POINT=POINT*m
GRAPH POINTS: POINT(1)/POINT(4),POINT(2)/POINT(4)
END SUB

Example.
1010 OPTION ARITHMETIC NATIVE
1020 OPTION ANGLE DEGREES
1030 DECLARE EXTERNAL SUB Plot3d.PLOT, Plot3d.PenUp, PlotLabel
1040 DECLARE PICTURE Lorenz
1050 DECLARE NUMERIC theta0, tx, ty
1060 LET theta0=45 ! Rotation angle about the z-axis
1070 LET tx=-60 ! Rotation angle about the x-axis
1080 LET ty=0 ! Rotation angle about the y-axis
1150 DIM m(4,4),mm(4,4)
1160 MAT m=ROTATE(theta0)
1170 SET POINT STYLE 1
1180 SET WINDOW -120, 120, -60, 180
1200 DIM rotx(4,4) ! rotation about x-axis
1210 MAT rotx=IDN
1220 LET rotx(2,2)=COS(tx)
1230 LET rotx(2,3)=SIN(tx)
1240 LET rotx(3,2)=-SIN(tx)
1250 LET rotx(3,3)=COS(tx)
1260 DIM roty(4,4) ! rotation about y-axis
1270 MAT roty=IDN
1280 LET roty(1,1)=COS(ty)
1290 LET roty(1,3)=-SIN(ty)
1300 LET roty(3,1)=SIN(ty)
1310 LET roty(3,3)=COS(ty)
1320 MAT m=m * rotx * roty
1330 DRAW Lorenz WITH m
1500 DECLARE NUMERIC s,b,r,t,dt,x,y,z,xx,yy,zz
1510 PICTURE Lorenz
1530 LET s=11
1540 LET b=8/4
1550 LET r=88
1560 LET x=15
1570 LET y=25
1580 LET z=75
1590 LET dt=1/256
1600 FOR t=0 TO 75 STEP dt
1610 LET xx=x+(-s*x+s*y)*dt
1620 LET yy=y+(r*x-y-x*z)*dt
1630 LET zz=z+(-b*z+x*y)*dt
1640 LET x=xx
1650 LET y=yy
1660 LET z=zz
1670 CALL PLOT(x,y,z)
1680 NEXT t
1690 REM x-axis
1700 CALL PenUp
1710 CALL PLOT(0,0,0)
1720 CALL PLOT(50,0,0)
1730 CALL PLOTLABEL(50,0,0,"x")
1740 REM y-axis
1750 CALL PenUp
1760 CALL PLOT(0,0,0)
1770 CALL PLOT(0,50,0)
1780 CALL PLOTLABEL(0,50,0,"y")
1790 REM z-axis
1800 CALL PenUp
1810 CALL PLOT(0,0,0)
1820 CALL PLOT(0,0,180)
1830 CALL PLOTLABEL(0,0,180,"z")
1840 CALL PenUp
1850 END PICTURE
1860 END
2000 MODULE PLot3D
2010 MODULE OPTION ARITHMETIC NATIVE
2020 PUBLIC SUB PLOT
2030 SHARE NUMERIC x0,y0
2040 SHARE NUMERIC PenState
2050 LET PenState=0
2060 EXTERNAL SUB PLOT(x,y,z)
2070 DECLARE NUMERIC POINT(4)
2080 DECLARE NUMERIC m(4,4)
2090 DECLARE NUMERIC xx,yy
2100 MAT m=TRANSFORM
2110 LET POINT(1)=x
2120 LET POINT(2)=y
2130 LET POINT(3)=z
2140 LET POINT(4)=1
2150 MAT POINT=POINT*m
2160 LET xx=POINT(1)/POINT(4)
2170 LET yy=POINT(2)/POINT(4)
2180 IF PenState<>0 THEN GRAPH LINES:x0,y0; xx,yy
2190 LET x0=xx
2200 LET y0=yy
2210 LET PenState=1
2220 END SUB
2230 EXTERNAL SUB PenUp
2240 LET PenState=0
2250 END SUB
2260 END MODULE
3000 EXTERNAL SUB PLOTLABEL(x,y,z,s$)
3010 OPTION ARITHMETIC NATIVE
3020 DIM m(4,4)
3030 MAT m=TRANSFORM
3040 DIM POINT(4)
3050 LET POINT(1)=x
3060 LET POINT(2)=y
3070 LET POINT(3)=z
3080 LET POINT(4)=1
3090 MAT POINT=POINT*m
3100 GRAPH TEXT ,AT POINT(1)/POINT(4),POINT(2)/POINT(4):s$
3110 END SUB


Reply to #78970

Reply to #78990×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-10 09:41 by SHIRAISHI Kazuo #79006)

Example of plotting a function z=f(x,y)

OPTION ARITHMETIC NATIVE
OPTION ANGLE DEGREES
DECLARE EXTERNAL SUB Plot3d.PLOT, Plot3d.PenUp, PlotLabel
DEF f(x,y)=COS(64*SQR(x^2+y^2))
DECLARE NUMERIC x,y,z
PICTURE F_GRAPH
FOR x=-4 TO 4 STEP 0.25
FOR y=-4 TO 4 STEP 0.25
LET z=f(x,y)
!PRINT x,y,z
CALL PLOT(x,y,z)
NEXT y
CALL PenUp
NEXT x
CALL PenUp
FOR y=-4 TO 4 STEP 0.25
FOR x=-4 TO 4 STEP 0.25
LET z=f(x,y)
CALL PLOT(x,y,z)
NEXT x
CALL PenUp
NEXT y
CALL PenUp
CALL PLOT(0,0,0)
CALL PLOT(5,0,0)
CALL PLOTLABEL(5,0,0,"x")
REM y-axis
CALL PenUp
CALL PLOT(0,0,0)
CALL PLOT(0,5,0)
CALL PLOTLABEL(0,5,0,"y")
REM z-axis
CALL PenUp
CALL PLOT(0,0,0)
CALL PLOT(0,0,5)
CALL PLOTLABEL(0,0,5,"z")
CALL PenUp
END PICTURE

DECLARE NUMERIC theta0, tx, ty
LET theta0=45 ! Rotation angle about the z-axis
LET tx=-60 ! Rotation angle about the x-axis
LET ty=0 ! Rotation angle about the y-axis
DIM m(4,4),mm(4,4)
MAT m=ROTATE(theta0)
SET POINT STYLE 1
SET WINDOW -4, 4, -3, 5
DO
DIM rotx(4,4) ! rotation about x-axis
MAT rotx=IDN
LET rotx(2,2)=COS(tx)
LET rotx(2,3)=SIN(tx)
LET rotx(3,2)=-SIN(tx)
LET rotx(3,3)=COS(tx)
DIM roty(4,4) ! rotation about y-axis
MAT roty=IDN
LET roty(1,1)=COS(ty)
LET roty(1,3)=-SIN(ty)
LET roty(3,1)=SIN(ty)
LET roty(3,3)=COS(ty)
MAT m=m * rotx * roty
SET DRAW mode hidden
CLEAR
DRAW F_GRAPH WITH m
PLOT TEXT, AT -2,-2: "Drag with mouse on the screen, and right click to finish."
SET DRAW mode explicit
DECLARE NUMERIC xx,yy,l,r,x0,y0
MOUSE POLL xx,yy,l,r
IF r<>0 THEN EXIT DO
LET tx=0
LET ty=0
IF l<>0 THEN
LET tx=-20*(yy-y0)
LET ty= 20*(xx-x0)
END IF
LET x0=xx
LET y0=yy
loop
END
MODULE PLot3D
MODULE OPTION ARITHMETIC NATIVE
PUBLIC SUB PLOT
SHARE NUMERIC x0,y0
SHARE NUMERIC PenState
LET PenState=0
EXTERNAL SUB PLOT(x,y,z)
DECLARE NUMERIC POINT(4)
DECLARE NUMERIC m(4,4)
DECLARE NUMERIC xx,yy
MAT m=TRANSFORM
LET POINT(1)=x
LET POINT(2)=y
LET POINT(3)=z
LET POINT(4)=1
MAT POINT=POINT*m
LET xx=POINT(1)/POINT(4)
LET yy=POINT(2)/POINT(4)
IF PenState<>0 THEN GRAPH LINES:x0,y0; xx,yy
LET x0=xx
LET y0=yy
LET PenState=1
END SUB
EXTERNAL SUB PenUp
LET PenState=0
END SUB
END MODULE
EXTERNAL SUB PLOTLABEL(x,y,z,s$)
OPTION ARITHMETIC NATIVE
DIM m(4,4)
MAT m=TRANSFORM
DIM POINT(4)
LET POINT(1)=x
LET POINT(2)=y
LET POINT(3)=z
LET POINT(4)=1
MAT POINT=POINT*m
GRAPH TEXT ,AT POINT(1)/POINT(4),POINT(2)/POINT(4):s$
END SUB






Reply to #78990

Reply to #79006×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: 3D-graphs (2016-11-10 15:35 by BSpinoza #79007)

Thank you very much for al this nice examples. This is a great help for me.
Decimal BASIC is fantastic.
Reply to #79006

Reply to #79007×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login