Informática Elemental
Small Basic: Triángulos y punto medio de una recta (código)
Trazado de triángulos con base en la recta que pasa (corta) a otra recta por su punto medio
código:
- ‘ x1 < o > x2
- TextWindow.WriteLine(“Input x1″)
- x1 = TextWindow.ReadNumber()
- TextWindow.WriteLine(“Input y1″)
- y1 = TextWindow.ReadNumber()
- TextWindow.WriteLine(“Input x2″)
- x2 = TextWindow.ReadNumber()
- TextWindow.WriteLine(“Input y2″)
- y2 = TextWindow.ReadNumber()
- ‘ m is the slope of the line
- m = (y2-y1) / (x2-x1)
- x = (x1 + x2)/2
- y= (y1 + y2)/2
- TextWindow.WriteLine(“the slope of the line is : ” + m)
- GraphicsWindow.PenWidth = 1
- GraphicsWindow.PenColor = “Red”
- GraphicsWindow.DrawLine(x1, y1, x2, y2)
- GraphicsWindow.PenWidth= 1
- GraphicsWindow.PenColor= “Blue)
- GraphicsWindow.DrawEllipse(x1,y1, 10,10)
- GraphicsWindow.DrawEllipse(x2,y2, 10,10)
- GraphicsWindow.PenWidth = 1
- GraphicsWindow.PenColor = “Red”
- GraphicsWindow.DrawBoundText(x, y,20, ” medio “)
- GraphicsWindow.DrawLine(x, y, x + 200, y)
- GraphicsWindow.DrawLine(x, y, x – 200, y)
- GraphicsWindow.PenColor = “Cyan”
- GraphicsWindow.DrawLine(x + 200, y, x1, y1)
- GraphicsWindow.DrawLine(x – 200, y, x1, y1)
- GraphicsWindow.DrawLine(x + 200, y, x2, y2)
- GraphicsWindow.DrawLine(x – 200, y, x2, y2)
- ‘ slope = m = (y2 – y1) / (x2 – x1) = elevation / traveled. for x1 different from x2
- tangent = y2-y1 / x2-x1
- ‘ distance = d
- a= Math.Power(x2- x1, 2)
- b = Math.Power(y2-y1, 2)
- c = a + b
- d = Math.SquareRoot(c)
- TextWindow.WriteLine(“the distance is : “
No comments:
Post a Comment