Questions tagged [line-segment]

90 questions
3
votes
1 answer

Detect if two line segments intersect using Cramer

I have used the code that has been posted here. Here is the code again: from __future__ import division def line(p1, p2): A = (p1[1] - p2[1]) B = (p2[0] - p1[0]) C = (p1[0]*p2[1] - p2[0]*p1[1]) return A, B, -C def intersection(L1,…
rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
3
votes
1 answer

Finding intersection points of line paths

I have two Bezier curves which share an end point. Each of these curves has an "extension" on both the left and right sides, similar to the edges of a road. The extensions are made of line segments that approximate the Bezier curve. I want to find…
3
votes
1 answer

Arc and line segment collision detection

How do I check the distance between a line segment and an arc? The arc is unfilled, so just the outer edge of the circle it is part of counts. I want to do collision detection. Basically I have two circular objects. One is moving on a line, and the…
ronalchn
  • 12,225
  • 10
  • 51
  • 61
2
votes
1 answer

Using PathIterator to return all line segments that constrain an Area?

In Java, how would one employ PathIterator to iterate through the line segments that constrain an Area? The Area is bound only by lines (but curve support wouldn't hurt). The method should return a collection of all the line segments.
Peter
  • 4,021
  • 5
  • 37
  • 58
2
votes
2 answers

Determine if Line Segment Between Polygon Vertices is "Inside" Polygon

I'm trying to find an efficient algorithm that can check if a line between two vertices in a simple (edit: simple concave) polygon contains points that lie outside the domain of the polygon. The closest question I could find is this one:…
2
votes
3 answers

Find cells in array that are crossed by a given line segment

I have got a 2D array of cells with size 10x10, and many points that are pairs of floating point values, like: (1.6, 1.54), (4.53, 3.23). The pairs (x,y) are such that x<10 and y<10 Each cell takes points whose coordinates have the same integer…
Mateusz
  • 604
  • 8
  • 20
2
votes
1 answer

Intersecting 3D line Segments

How do I determine whether or not two 3D line segments intersect given XYZ coordinates for the start and end points of each line? If they do intersect, at what XYZ? I've only been able to find answers for 2D: How do you detect where two line…
D. Neller
  • 21
  • 1
  • 4
2
votes
1 answer

calculate intersection between two segments in a symmetric way

When using the usual formulas to calculate intersection between two 2D segments, ie here, if you round the result to an integer, you get non-symmetric results. That is, sometimes, due to rounding errors, I get that…
Elazar Leibovich
  • 32,750
  • 33
  • 122
  • 169
2
votes
1 answer

Calculate if Two Particles Come Close

I'm doing some simple collision detection for a 2D game in PSM Studio. My current method involves iterating through every game object and finding the distance between another game object, then seeing if the two are within a certain distance (usually…
watswat5
  • 671
  • 1
  • 7
  • 19
2
votes
2 answers

Point and line segment intersection point. Both moving

How would I tell the time and point of intersection between a moving Point at a fixed velocity and a Line Segment whose end-points are moving? The endpoints move independently, but only in the positive y direction, and also at fixed…
1
vote
1 answer

Why does this simple LineSegment jump from canvas centre-bottom to top-left in Silverlight?

I have some very simple code that 'correctly' draws a short vertical black line on a 1024x768 blue canvas in WPF (well in Silverlight 4).
dumbledad
  • 16,305
  • 23
  • 120
  • 273
1
vote
0 answers

Finding pixel closest (grid points) to rectilinear polygons

I have rectilinear polygons present, and they are surrounded by grids(grey rectangle with dots denoting center) as shown in the diagram below. The grids are perfectly stacked horizontally and vertically. I have with me the coordinates of the edges…
1
vote
2 answers

Is there a way in R to find the perpendicular distance between a point and a line segment?

This question was answered here, but not answered in R language. I am a relatively new to coding, so I haven't been able to figure out how to 'translate' the accepted answer's C++ code into R code. As in the linked question, my line segment is…
LGH14
  • 21
  • 2
1
vote
1 answer

THREE.LineSegments - geometry.needsUpdate is not updating

Hi I cannot get my THREE.LineSegments to update using geometry.needsUpdate. I have a quick animation that, with each iteration, draws one side of a square, starting on the left upright and then going round in a clockwise motion and drawing each side…
cannon303
  • 403
  • 2
  • 12
1
vote
0 answers

THREE.js EdgesGeometry / LineSegments showing to much lines

I've got a BufferGeometry from which I extract the edges and display the lines: const geometry = new THREE.BufferGeometry(); geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); const edges = new…