Small Basic: Triángulos y punto medio de una recta (código)

pendiente

Trazado de triángulos con base en la recta que pasa (corta) a otra recta por su punto medio
código:
  1. ‘ x1 < o > x2
  2. TextWindow.WriteLine(“Input x1″)
  3. x1 = TextWindow.ReadNumber()
  4. TextWindow.WriteLine(“Input y1″)
  5. y1 = TextWindow.ReadNumber()
  6. TextWindow.WriteLine(“Input x2″)
  7. x2 = TextWindow.ReadNumber()
  8. TextWindow.WriteLine(“Input y2″)
  9. y2 = TextWindow.ReadNumber()
  10. ‘ m is the slope of the line
  11. m = (y2-y1) / (x2-x1)
  12. x = (x1 + x2)/2
  13. y= (y1 + y2)/2
  14. TextWindow.WriteLine(“the slope of the line is : ” + m)
  15. GraphicsWindow.PenWidth = 1
  16. GraphicsWindow.PenColor = “Red”
  17. GraphicsWindow.DrawLine(x1, y1, x2, y2)
  18. GraphicsWindow.PenWidth= 1
  19. GraphicsWindow.PenColor= “Blue)
  20. GraphicsWindow.DrawEllipse(x1,y1, 10,10)
  21. GraphicsWindow.DrawEllipse(x2,y2, 10,10)
  22. GraphicsWindow.PenWidth = 1
  23. GraphicsWindow.PenColor = “Red”
  24. GraphicsWindow.DrawBoundText(x, y,20, ” medio “)
  25. GraphicsWindow.DrawLine(x, y, x + 200, y)
  26. GraphicsWindow.DrawLine(x, y, x – 200, y)
  27. GraphicsWindow.PenColor = “Cyan”
  28. GraphicsWindow.DrawLine(x + 200, y, x1, y1)
  29. GraphicsWindow.DrawLine(x – 200, y, x1, y1)
  30. GraphicsWindow.DrawLine(x + 200, y, x2, y2)
  31. GraphicsWindow.DrawLine(x – 200, y, x2, y2)
  32. ‘ slope = m = (y2 – y1) / (x2 – x1) = elevation / traveled. for x1 different from x2
  33. tangent = y2-y1 / x2-x1
  34. ‘ distance = d
  35. a= Math.Power(x2- x1, 2)
  36. b = Math.Power(y2-y1, 2)
  37. c = a + b
  38. d = Math.SquareRoot(c)
  39. TextWindow.WriteLine(“the distance is : “