About 4,820,000 results
Open links in new tab
  1. python - Closest distance between two lines - Stack Overflow

    Jun 9, 2014 · I want to make a function to get the closest/shortest distance between any two lines (assuming they don't intersect). I know there are several posts about the shortest distance between a point and a line, but I couldn't find any for two lines.

  2. Python Class for Distances - Stack Overflow

    Mar 17, 2014 · I am trying to calculate the distance between 2 points using classes. #This initializes our class and says that if x,y co-ords are not given then. #the default is x=0, y=0. def __init__(self,x=0,y=0): self.move(x,y) #move the point to a new location in 2D space. def move(self,x,y): self.x=x. self.y=y. #reset the point back to the origin.

  3. Calculate distance and slope of a line in Python

    Apr 22, 2023 · In this article, we'll explore how to implement a Line class in Python that calculates the distance and slope between two points. We'll also discuss some possible optimizations to make the code more efficient and maintainable.

  4. Shortest Distance between Two Lines.py - GitHub

    LP1 = eval(input("Enter Coordinate through which Line 1 passes : ")) LC2 = eval(input("Enter DRs of Line 2 : ")) LP2 = eval(input("Enter Coordinate through which Line 2 passes : "))

  5. Program to calculate distance between two points

    Feb 10, 2025 · Calculate the distance between two points. We will use the distance formula derived from Pythagorean theorem. The formula for distance between two point (x1, y1) and (x2, y2) is. Below is the implementation of above idea.

  6. Python Program to Calculate Distance Between Two Points

    This python program calculates distance between two points or coordinates given by user using distance formula. This program uses following formula for distance between two points: Distance Formula = ( (x2 - x1)2 + (y2 - y1)2 )½. Where: (x1, y1) = coordinates of the first point & (x2, y2) = coordinates of the second point.

  7. How to calculate the distance between two points on lines in python

    Calculating the distance between two points on a line in Python can be done using various methods, such as the Euclidean distance formula, the Pythagorean theorem, or vector subtraction. Here, I’ll provide you with detailed explanations and at least 10 code examples using different approaches.

  8. python - How to calculate the distance between two lines

    Jan 23, 2021 · Use Python's max function on the (list of) found contours using cv2.contourArea as key to get the largest contour. Finally, use cv2.boundingRect to get the bounding rectangle of the contour. That's a tuple (x, y, widht, height). Just use the last two elements, and you have your desired information. That'd be my code:

  9. python - Distance between point and a line (from two points)

    You can use haggis.math.segment_distance to compute the distance to the entire line (not just the bounded line segment) like this: d = haggis.math.segment_distance(P3, P1, P2, segment=False) Share

  10. Distance between two points! - Python Forum

    Apr 28, 2017 · Write a python program that declares a function named distance. The purpose of the function is to calculate the distance between two points and return the result. The function should define 4 parameter variables.

  11. Some results have been removed
Refresh