Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8123

Animating morphing Bezier curves; saving points

From Chris Young <cy56@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Animating morphing Bezier curves; saving points
Date 2012-01-24 10:08 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jflvut$jql$1@smc.vnet.net> (permalink)

Show all headers | View raw


The problem is that every time I start the animation, I lose the
positions of my points.

http://home.comcast.net/~cy56/Mma/MorphingB=C3=A9zier.nb
http://home.comcast.net/~cy56/Mma/MorphingB=C3=A9zierPic.png


Manipulate[
 DynamicModule[
  {
   P == {      (*
     all the points *)
     {-1, -1}, {-1, -.5}, {-1, 0}, {-1, .5}, {-1, 1},
     {  1, -1}, {   1, -.5}, {  1, 0}, {   1, .5}, {  1, 1}
     },
   P1, P2,   (* the points for each B=C3=A9zier curve *)
   C1, C2,   (*
   the B=C3=A9zier curves *)
   PM,           (*
   the points for the morphing B=C3=A9zier curve *)
   CM              (*
   the morphing B=C3=A9zier curve *)
   },
 
  LocatorPane[
   Dynamic[P],
   
   P1 == Dynamic @ Take[P, {1, 5}];
   P2 == Dynamic @ Take[P, {6, 10}];
  
   PM[n_] == (1 - n) P1 + n P2;
  
   C1 == BezierCurve[P1, SplineDegree -> 5];
   C2 == BezierCurve[P2, SplineDegree -> 5];
  
   CM[n_] == BezierCurve[PM[n], SplineDegree -> 5];
  
   Graphics[
    {
     Thick,
     Red, C1,
     Blue, C2,
     Purple, CM[n],
    
     Thin, Black, Dashed,
     Line[P1],
     Line[P2]
     },
    Axes -> True,
    PlotRange -> {{-1, 1}, {-1, 1}},
    GridLines -> {Range[-1, 1, .25], Range[-1, 1, .25]},
    GridLinesStyle -> LightGray
    ],
   {{-1, -1}, {1, 1}, {.25, .25}},
   LocatorAutoCreate -> True
   ]
  ],
 {{n, 0}, 0, 1}
 ]

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Animating morphing Bezier curves; saving points Chris Young <cy56@comcast.net> - 2012-01-24 10:08 +0000
  Re: Animating morphing Bezier curves; saving points Chris Young <cy56@comcast.net> - 2012-01-25 11:59 +0000

csiph-web