Constructing a parallel line segment

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Constructing a parallel line segment

billy
I'm using the 2D Arrangements package, and I want to construct the boundary
of a "hippodrome" around a line segment. Here's what it looks like around a
line segment 'e' https://imgur.com/UYNte2Q
To do this I'm trying to construct the two parallel line segments, and then
the two semicircles. The trouble is actually constructing those 4 points
where the parallel segments meet the semicircles.
If I could construct a vector perpendicular to the line segment with
magnitude r, I could construct a Transform from this vector and apply that
to the line segment and I'd be done. The Vector_2 class does support
constructing perpendicular vectors, but there seems to be no clear way to
make this vector have a chosen magnitude. The Direction_2 class says it
doesn't do normalisation, so it doesn't seem clear at all how to construct a
unit vector perpendicular to the line segment.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Constructing a parallel line segment

Efi Fogel
You should probably look at the approximated_offset_2() and offset_polygon_2() functions of the "2D Minkowski Sums" package.
The operations you are trying to apply, e.g., normalizing a vector, requires square-root.
If you don't want to compromise with the exact solution, you will have to use a number type that supports square-root (see offset_polygon_2()).
Otherwise, you can obtain an approximation (see approximated_offset_2()).
   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/




On Thu, 21 Nov 2019 at 05:10, billy <[hidden email]> wrote:
I'm using the 2D Arrangements package, and I want to construct the boundary
of a "hippodrome" around a line segment. Here's what it looks like around a
line segment 'e' https://imgur.com/UYNte2Q
To do this I'm trying to construct the two parallel line segments, and then
the two semicircles. The trouble is actually constructing those 4 points
where the parallel segments meet the semicircles.
If I could construct a vector perpendicular to the line segment with
magnitude r, I could construct a Transform from this vector and apply that
to the line segment and I'd be done. The Vector_2 class does support
constructing perpendicular vectors, but there seems to be no clear way to
make this vector have a chosen magnitude. The Direction_2 class says it
doesn't do normalisation, so it doesn't seem clear at all how to construct a
unit vector perpendicular to the line segment.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss