# Calculation of geometric figures and their graphs

• ### Question

• I was looking at:
Easy Input data Graf Controlbox making version 2011/12/21 by NaoChanON
Easy Graf 2011/12/21 by making NaoChanON

But I can not think how to calculate perimeters and areas of simple shapes: triangles, rectangles and tapered and polyhedra and draw the graphs
may be  there are already some examples
thanks

carlosfmur - Buenos Aires

Friday, May 3, 2013 2:37 PM

• carlosfmur, I modified your triangle program as WGZ319.

Nonki Takahashi

Monday, May 6, 2013 2:36 PM

### All replies

• I can not find the references above, but I made a program to calculate some parameters of a triangle:

```GraphicsWindow.Show()
GraphicsWindow.Height=500
GraphicsWindow.Width=500
For i=100 to 400 step 100
GraphicsWindow.DrawLine(100,i,400,i)
GraphicsWindow.DrawText(70,i-10,i-100)
GraphicsWindow.DrawLine(i,100,i,400)
GraphicsWindow.DrawText(i-10,80,i-100)
endfor
GraphicsWindow.DrawText(10,10,"Click three")
GraphicsWindow.DrawText(10,30,"   times ")
GraphicsWindow.DrawText(10,50,"  in grid")
GraphicsWindow.MouseDown=Mous
For i=1 to 3
mxx=0
While mxx=0
EndWhile
mx[i]=mxx-100
my[i]=myy-100
GraphicsWindow.FillEllipse(mxx-2,myy-2,5,5)
GraphicsWindow.DrawText(mxx+4,myy-10,i)
GraphicsWindow.DrawText(100,20*i,"Point "+i+"  : "+mx[i]+"    "+my[i])
endfor
GraphicsWindow.DrawLine(mx[1]+100,my[1]+100,mx[2]+100,my[2]+100)
GraphicsWindow.DrawLine(mx[1]+100,my[1]+100,mx[3]+100,my[3]+100)
GraphicsWindow.DrawLine(mx[3]+100,my[3]+100,mx[2]+100,my[2]+100)
s12= Math.SquareRoot((mx[1]-mx[2])*(mx[1]-mx[2])+(my[1]-my[2])*(my[1]-my[2]))
r12= Math.Round(s12*100)/100
GraphicsWindow.DrawText(300,20,"Side 1-2 :"+r12)
s13= Math.SquareRoot((mx[1]-mx[3])*(mx[1]-mx[3])+(my[1]-my[3])*(my[1]-my[3]))
r13= Math.Round(s13*100)/100
GraphicsWindow.DrawText(300,40,"Side 1-3 :"+r13)
s23= Math.SquareRoot((mx[3]-mx[2])*(mx[3]-mx[2])+(my[3]-my[2])*(my[3]-my[2]))
r23= Math.Round(s23*100)/100
GraphicsWindow.DrawText(300,60,"Side 2-3 :"+r23)
circ=r12+r13+r23
GraphicsWindow.DrawText(50,430,"Circumference: "+circ)
area2=circ/2*(circ/2-s12)*(circ/2-s13)*(circ/2-s23)
area= Math.SquareRoot(area2)
GraphicsWindow.DrawText(50,460,"    Area     :    "+Math.Round(area*100)/100)

sub mous
mxx= GraphicsWindow.MouseX
myy= GraphicsWindow.MouseY
EndSub
```

I hope you can use this.

Jan [ WhTurner ] The Netherlands

Friday, May 3, 2013 6:01 PM
• Saturday, May 4, 2013 1:51 AM
• Saturday, May 4, 2013 2:40 AM
• Does tapered mean trapezoid? Does polyhedra mean regular polygons?

Nonki Takahashi

Saturday, May 4, 2013 4:21 AM
• Saturday, May 4, 2013 4:44 AM
• I wrote a program XQF852 for rectangle.

Nonki Takahashi

Saturday, May 4, 2013 5:50 AM
• I wrote a program XQF852-1 for trapezoid.

Upper base should be less equal than lower base for this program.

Nonki Takahashi

Saturday, May 4, 2013 6:38 AM
•   Thank you very much for your help
I will study it and I'll tell you my results
Best Regards

carlosfmur - Buenos Aires

Saturday, May 4, 2013 12:30 PM
•   tapered. I mean:  Conic: allintersection curves between a cone and a plane, if the plane does not pass through the vertex, we obtain the proper taper. (sorry for my english)

Polyhedron: A solid figure whose faces are flat and contain a finite volume
For example tetrahedron (four-sided), pentahedron (5) hexahedron (6), heptaedro (7), ... icosahedron (20) -

Thanks and excuse me

carlosfmur - Buenos Aires

Saturday, May 4, 2013 12:42 PM
•

Try this one of NaoChanOn
I'm looking calculate, for example, the perimeter and area of ​​a triangle
a = 10 cm, b = 4 cm and c = 3 cm
and that the program will draw and fill that figure on screen
I Don´t know if I'm clear
Thank you very much and greetings

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

' Easy Graf making 2011/12/21 by NaoChanON

init()

data()

Plot_Data()

Sub init

GraphicsWindow.top=50

GraphicsWindow.Left=50

GraphicsWindow.Width=1000

GraphicsWindow.Height=600

GraphicsWindow.Show()

GraphicsWindow.BackgroundColor="Lightcyan"

GraphicsWindow.BrushColor="Navy"

GraphicsWindow.PenColor="Red"

' Draw Rectangle

GTop=60

GLeft=150

GWidth=800

GHeight=450

GraphicsWindow.DrawRectangle(Gleft,Gtop,GWidth,GHeight)

' Title and X,Y-labels

GraphicsWindow.FontSize=30

Shapes.Animate(GTitle,Gleft+150,Gtop-40,1000)

Shapes.Animate(LabelY,35,(Gtop+GHeight)/2,1500)

Shapes.Rotate(LabelY,-90)

Shapes.Animate(LabelX,(Gleft+Gwidth)/2-20,Gtop+GHeight+40,2000)

' X-----Axis

GraphicsWindow.FontSize=20

GraphicsWindow.BrushColor="Red"

MinX=10           ' Minimum X value of X-axis

MaxX=160          ' Maximum X value of X-axis

XDiv=5            ' dividing number

For i= 0 To XDiv

For j=GTop To GTop+Gheight-5 Step 10

GraphicsWindow.DrawLine(Gleft+i*(Gwidth/Xdiv),J,Gleft+i*(Gwidth/Xdiv),j+5)

EndFor

DivX=math.round(minX+i*((MaxX-minX)/Xdiv))

GraphicsWindow.DrawText(Gleft+i*(Gwidth/Xdiv)-20,GTop+GHeight+10,DivX)

EndFor

' Y---Axis

MinY=20            ' Minimum Y value of Y-axis

MaxY=170           ' Maximum Y value of Y-axis

YDiv=5             ' dividing number

For i= YDiv To 0 Step -1

For j=GLeft To GLeft+Gwidth-5 Step 10

GraphicsWindow.DrawLine(j,GTop+i*(GHeight/Ydiv),j+5,GTop+i*(GHeight/Ydiv))

EndFor

DivY=math.Round(MaxY-i*((MaxY-minY)/Ydiv))

GraphicsWindow.DrawText(Gleft-40,GTop+i*(GHeight/Ydiv)-10,DivY)

EndFor

EndSub

Sub  Plot_Data     ' <st1:street w:st="on"><st1:address w:st="on">Green Circle</st1:address></st1:street> ; Graphic drawing or shapes animating

GraphicsWindow.PenColor="Green"

GraphicsWindow.PenWidth=3

For i=1 To NN

plotx=Gleft + (PX[i]-minX)*Gwidth/(MaxX-MinX)

ploty=GTop + Gheight- (PY[i]-minY)*Gheight/(MaxY-MinY)

'GraphicsWindow.FillEllipse(plotx,ploty,10,10)

Shapes.Animate(sc[i],plotx-5,ploty-5,1000)

EndFor

EndSub

1. Sub  data         ' X data and Y data
2. d[1]="10,30"
3. d[2]="15,35"
4. d[3]="20,40"
5. d[4]="25,43"
6. d[5]="30,50"
7. d[6]="60,74"
8. d[7]="80,80"
9. d[8]="85,102"
10. d[9]="103,114"
11. d[10]="120,130"

1. NN=10    ' data number is 10 ; see above

1. For i=1 To NN     ' X,Y data are divided and stored      here.
2. midP=text.GetIndexOf(d[i],",")            'delimiter is ","
3. PX[i]=text.GetSubText(d[i],1,midp-1)
4. PY[i]=text.GetSubTextToEnd(d[i],midp+1)
5. EndFor
1. EndSub

carlosfmur - Buenos Aires

Saturday, May 4, 2013 8:49 PM
•

Yes, yes. Edited by NaoChanOn

But I´m trying another thing

Thanks, Nonki

carlosfmur - Buenos Aires

Saturday, May 4, 2013 8:51 PM
•

I tried your  XQF852 and is very good

Thank you

carlosfmur - Buenos Aires

Saturday, May 4, 2013 8:57 PM
•    I mean

how to calculate  x1, y1   x2, y2 and x3, y3 to GraphicsWindow draw it

The same foranygeometric figure

Thank and best regards

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

'Area of a triangle
TextWindow.WriteLine ("enter the value of the base of the triangle")
TextWindow.WriteLine ("enter the value of the height of the triangle")
area = (base * height) / 2
TextWindow.WriteLine ("The area is" + Area)

GraphicsWindow.Width = 240
GraphicsWindow.Height = 240
GraphicsWindow.BrushColor
Shapes.AddTriangle triangle = (x1, y1, x2, y2, x3, y3)

carlosfmur - Buenos Aires

Saturday, May 4, 2013 9:11 PM
•   Hello Noki
I ran and save your Trapezoid (XQF852-1)
I found it excellent. congratulations
Thanks and regards

carlosfmur - Buenos Aires

Saturday, May 4, 2013 11:19 PM
•    I mean

how to calculate  x1, y1   x2, y2 and x3, y3 to GraphicsWindow draw it

The same foranygeometric figure

Thank and best regards

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

'Area of a triangle
TextWindow.WriteLine ("enter the value of the base of the triangle")
TextWindow.WriteLine ("enter the value of the height of the triangle")
area = (base * height) / 2
TextWindow.WriteLine ("The area is" + Area)

GraphicsWindow.Width = 240
GraphicsWindow.Height = 240
GraphicsWindow.BrushColor
Shapes.AddTriangle triangle = (x1, y1, x2, y2, x3, y3)

carlosfmur - Buenos Aires

GraphicsWindow.BrushColor = "Cyan"
k = 0.3 ' 0 <= k <= 1
pxBase = base * 36
pxHeight = height * 36
x1 = pxBase * k
y1 = 0
x2 = pxBase
y2 = pxHeight
x3 = 0
y3 = y2
triangle = Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)
Shapes.Move(triangle, 100, 100)

Nonki Takahashi

Sunday, May 5, 2013 9:02 AM
• carlosfmur, I modified your triangle program as WGZ319.

Nonki Takahashi

Monday, May 6, 2013 2:36 PM
• I understand your tapered. (1) is parabola. (2) is ellipse. (3) is hyperbola.

(2) is easiest in these three.  We can modify rectangle program into ellipse program.  Ellipse has it's width and height.

But for (1) and (3), how do you define the parabola and the hyperbola?

Also polyhedron, how do you define it?  And what do you calculate for the polyhedron (also perimeter and area)?

Nonki Takahashi

Monday, May 6, 2013 3:02 PM
•

base variable and height not value assigned, Not run

GraphicsWindow.BrushColor = "Cyan"
k = 0.3 ' 0 <= k <= 1
pxBase = base * 36
pxHeight = height * 36
x1 = pxBase * k
y1 = 0
x2 = pxBase
y2 = pxHeight
x3 = 0
y3 = y2
triangle = Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)
Shapes.Move(triangle, 100, 100)

carlosfmur - Buenos Aires

Monday, May 6, 2013 9:32 PM
• carlosfmur　and　Nonki

Thank youpick up theprogramI created。　I was going to vacation until yesterday.

I guess What you want to do will be below?

If so, when m and n are decided a and b are obtained.

Tuesday, May 7, 2013 8:55 AM
• Nice approaching.  My understanding is as below.

Nonki Takahashi

Wednesday, May 8, 2013 8:11 AM