MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cubic Bezier Curves Intersection

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132088] Re: Cubic Bezier Curves Intersection
  • From: "E. Martin-Serrano" <eMartinSerrano at telefonica.net>
  • Date: Mon, 2 Dec 2013 02:00:02 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20131129084954.6B8E46A1D@smc.vnet.net> <20131130072525.202F86A27@smc.vnet.net>

Hi Bob,

With the following  minor additions your construct works smoothly in a
dynamic context;   by dragging the control points {pts1, pts2}  as locators,
the Bezier curves get reshaped and move synchronically with the intersection
point *xip*

xip = Quiet@
   NMinimize[{Norm[f1[x1] - f2[x2]], 0 <= x1 <= 1, 0 <= x2 <= 1}, {x1,  x2},
Method -> "RandomSearch", AccuracyGoal -> 8,
     WorkingPrecision -> 8][[2]];

Thank you.

E. Martin-Serrano

-----Mensaje original-----
De: Bob Hanlon [mailto:hanlonr357 at gmail.com]
Enviado el: s=E1bado, 30 de noviembre de 2013 8:25
Para: mathgroup at smc.vnet.net
Asunto: Re: Cubic Bezier Curves Intersection


pts1 = {{0, 0}, {1, 1}, {2, 0}, {3, 2}};


pts2 = {{1, 1}, {0, 0}, {3, 2}, {2, 0}};


Clear[f1, f2]


f1[x_] :=
  BezierFunction[pts1][x];


f2[x_] :=
  BezierFunction[pts2][x];


xip = NMinimize[{
    Norm[f1[x1] - f2[x2]],
    0 <= x1 <= 1, 0 <= x2 <= 1},
   {x1, x2}][[2]]


{x1 -> 0.700846, x2 -> 0.735816}


f1[x1] /. xip


{2.10254, 0.876654}


f2[x2] /. xip


{2.10254, 0.876654}


Show[
 Graphics[
  {Green, AbsolutePointSize[4], Point[pts1],
   Darker[Red], Point[f1[x1] /. xip]},
  Frame -> True],
 ParametricPlot[
  {f1[x], f2[x]}, {x, 0, 1}]]



Bob Hanlon




On Fri, Nov 29, 2013 at 3:49 AM, E. Martin-Serrano <
eMartinSerrano at telefonica.net> wrote:

> Hi,
>
> I would appreciate a  piece of Mathematica code implementing Cubic
> Bezier Curves Intersection.
>
> Any help either on the forum or  a notebook sent to the my  e-mail
> address will be welcome.
>
> Regards.
>
> E. Martin-Serrano
>
>
>
>






  • Prev by Date: Re: Creating a list of 1x2 element arrays without procedural programming
  • Next by Date: Re: Creating an ordered list of pairs
  • Previous by thread: Parameters for the Stereographic projection in GetProjectionData
  • Next by thread: Re: Creating a list of 1x2 element arrays without procedural