Hidden WordScanner
Private scans · No account required

DuckieDai Point-to-Line Distance

Calculate perpendicular distance from a point to a line written as Ax + By + C = 0.

Version 1.0.0 · Tested on a TI calculator

← Back to Calculator Program Library

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.

geometry · MIT License

Overview

Calculate perpendicular distance from a point to a line written as Ax + By + C = 0.

Usage

Inputs

  • Line coefficients A, B, and C
  • Point coordinates x0 and y0

Outputs

  • Perpendicular distance and an on-line notice when the distance is zero

Units: Coordinates and coefficients must use one consistent coordinate system.

Assumptions and limitations

Assumptions

  • The line is represented by Ax + By + C = 0.

Constraints

  • A and B cannot both be zero; entered values must remain between -1e100 and 1e100.

Known failures

  • An all-zero A and B pair is rejected.

Compatibility and review

Review status
Tested on a TI calculator
Tested on
TI-84 Plus CE Python; OS 5.8.3; Python App 5.8.3.0048; exact source owner-tested through TI Connect CE
What happened
Owner confirmed the supplied point to line distance program runs on the physical calculator.
Dependencies
math
Suggested calculator name
PTLINE — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Browser preview

Try point-to-line distance

This browser preview applies the perpendicular-distance formula to one line and point.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. """DuckieDai Point-Line Distance for TI-84 Plus CE Python."""
  2. from math import sqrt
  3. def duckiedai_intro(program_name, wait=True):
  4. """Show the reusable DuckieDai program opening."""
  5. title = program_name[:16]
  6. empty = 16 - len(title)
  7. left = empty // 2
  8. right = empty - left
  9. print("+----------------------+")
  10. print("| " + " " * left + title + " " * right + " |")
  11. print("| |")
  12. print("| __ |")
  13. print("| ___(o )> quack! |")
  14. print("| \\ <_. ) |")
  15. print("| `---' |")
  16. print("| by DuckieDai |")
  17. print("+----------------------+")
  18. print("Loading...")
  19. if wait:
  20. input("Press enter to start ")
  21. print("\n" * 6)
  22. def number(prompt):
  23. """Allow positive, negative, or zero values."""
  24. while True:
  25. try:
  26. value = float(input(prompt))
  27. if value > -1e100 and value < 1e100:
  28. return value
  29. except ValueError:
  30. pass
  31. print("Enter a valid number.")
  32. def get_line():
  33. """Get valid coefficients for Ax + By + C = 0."""
  34. while True:
  35. print("LINE:")
  36. print("Ax + By + C = 0")
  37. print()
  38. A = number("A: ")
  39. B = number("B: ")
  40. C = number("C: ")
  41. if A != 0 or B != 0:
  42. return A, B, C
  43. print()
  44. print("INVALID LINE")
  45. print("A and B cannot")
  46. print("both be zero.")
  47. print()
  48. def point_line_distance(A, B, C, x0, y0):
  49. """Return perpendicular distance from point to line."""
  50. numerator = abs(
  51. A * x0 +
  52. B * y0 +
  53. C
  54. )
  55. denominator = sqrt(
  56. A ** 2 +
  57. B ** 2
  58. )
  59. distance = numerator / denominator
  60. return numerator, denominator, distance
  61. def main():
  62. duckiedai_intro("POINT-LINE DIST")
  63. print("POINT TO LINE")
  64. print("DISTANCE")
  65. print()
  66. print("Line form:")
  67. print("Ax + By + C = 0")
  68. print()
  69. print("Formula:")
  70. print("|A*x0+B*y0+C|")
  71. print("----------------")
  72. print("sqrt(A^2+B^2)")
  73. print()
  74. A, B, C = get_line()
  75. print()
  76. print("POINT (x0, y0)")
  77. print()
  78. x0 = number("x0: ")
  79. y0 = number("y0: ")
  80. numerator, denominator, distance = \
  81. point_line_distance(
  82. A, B, C, x0, y0
  83. )
  84. print()
  85. print("Using:")
  86. print("d = |A*x0+B*y0+C|")
  87. print(" /sqrt(A^2+B^2)")
  88. print()
  89. print("Top =")
  90. print(str(numerator))
  91. print()
  92. print("Bottom =")
  93. print(str(denominator))
  94. print()
  95. print("ANSWER")
  96. print("Distance =")
  97. print(str(distance))
  98. print("units")
  99. if distance == 0:
  100. print()
  101. print("Point lies on")
  102. print("the line.")
  103. print()
  104. print("DuckieDai says: done!")
  105. # TI-Python imports the selected AppVar rather than
  106. # setting __name__ to main.
  107. main()
Filename
PTLINE.py
Size
3045 bytes
SHA-256
01930d1a4a1ad79ed564c62296cec16f6e3cb7b371ec0c98dd7957042ee0d4ff

Transfer and launch

  1. Confirm that your calculator is the Python-capable model named above. Check that its OS and Python App versions match the reviewed record.
  2. Download the .py source above and verify its SHA-256 digest if your computer provides that option.
  3. Use TI Connect CE to send the Python file to a compatible calculator. PTLINE is a suggested name; you may choose another valid, unique calculator name.
  4. Open the Python App, select the program, and check sample inputs before relying on other results.

Read the complete installation, launch, troubleshooting, and removal guide.

Availability does not mean a teacher, school, or exam permits this program. Follow the applicable rules.

Version history

Any source change requires a new immutable version and digest. Historical downloads remain available only while their review records remain valid.