XML Feeds

.

[jitter] atan2 and shortest path to point

Wesley Smith wesley.hoke at gmail.com
Mon Oct 22 09:43:28 MDT 2007


This is because you're dealing with 2 fundamentall diferent domains.
Let's take the 2D case.  The typical situation is a plane.  In polar,
you're dealing with a toroidal space where one value is strictly
positive and the other wraps at 2PI as you probably know.  Toroidal
spaces require a different understanding of coordinates and thus a
different interpolation methodology.  In other words, your distance
metric is completely wrong in the slide object.  slide assumes a 1D
cartesian coordinate and you're smoothing a 1D toroidal coordinate.
You'll need to do some extra math to make it work based on where the
coordinate wraps.

wes


> now, when i move the mouse from the top left of the jit.window to the bottom
> right the function is to dumb to know it can turn left insted of going the
> full circle to the correct position.
> i added a smaller circle without the slide to show the correct motion,
> simply following the atan2.
>
> hope its clearer.
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P comment 587 246 22 9109513 y x;
> #P newex 553 267 163 9109513 expr ((atan2($f1 \\\, $f2))/3.1415)*180.;
> #P objectname receive[1];
> #P newex 516 314 33 9109513 r draw;
> #P flonum 553 292 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P comment 590 292 44 9109513 degrees;
> #P message 553 245 31 9109513 \$2 \$1;
> #P message 553 316 82 9109513 rotatexyz 0. 0. \$1;
> #P window linecount 2;
> #P newex 536 341 259 9109513 jit.gl.gridshape rott @color 1 0 1 1 @scale 0.5
> 0.5 @position 0. 0. 0.01 @shape circle @texture grid @automatic 0;
> #P window linecount 1;
> #P comment 208 100 130 9109513 how to get the shortest path?;
> #P comment 382 208 22 9109513 y x;
> #P newex 186 35 45 9109513 loadbang;
> #P message 186 141 55 9109513 texture grid;
> #P newex 348 184 89 9109513 route screentoworld;
> #P message 143 245 91 9109513 screentoworld \$1 \$2;
> #P newex 143 221 74 9109513 route mouseidle;
> #P newex 143 267 42 9109513 s render;
> #P newex 348 229 163 9109513 expr ((atan2($f1 \\\, $f2))/3.1415)*180.;
> #P objectname receive[4];
> #P newex 297 247 27 9109513 t b b;
> #P newex 297 194 33 9109513 r draw;
> #P newex 314 270 27 9109513 f 0.;
> #P newex 314 292 59 9109513 slide 50. 50.;
> #P flonum 348 254 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P comment 385 254 44 9109513 degrees;
> #P message 348 207 31 9109513 \$2 \$1;
> #P message 314 317 82 9109513 rotatexyz 0. 0. \$1;
> #P window linecount 2;
> #P newex 297 342 210 9109513 jit.gl.gridshape rott @color 1 1 1 1 @shape
> circle @texture grid @automatic 0;
> #P window linecount 1;
> #P newex 103 141 35 9109513 s draw;
> #P newex 140 141 40 9109513 r render;
> #N vpatcher 530 245 771 446;
> #P origin 64 -4;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 51 84 40 9109513 sel 0 1;
> #P message 51 128 152 9109513 border 1 \, size 320 240 \, pos 10 463;
> #P message 66 107 160 9109513 border 0 \, size 1024 778 \, \, pos 1024 0;
> #P toggle 51 66 15 0;
> #P window linecount 0;
> #P newex 50 44 35 9109513 sel 27;
> #P newex 50 21 40 9109513 key;
> #P outlet 56 154 15 0;
> #P fasten 1 0 2 0 55 42 55 42;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P fasten 6 0 5 0 56 106 56 106;
> #P connect 4 0 0 0;
> #P connect 5 0 0 0;
> #P connect 6 1 4 0;
> #P pop;
> #P newobj 40 162 25 9109513 p fs;
> #P window linecount 2;
> #P newex 40 184 178 9109513 jit.window rott @size 320 240 @floating 1 @pos
> 10 450 @idlemouse 1;
>  #P objectname jit.window;
> #P window linecount 1;
> #P newex 79 162 279 9109513 jit.gl.render rott @camera 0 0 3 @erase_color 0.
> 0. 0. 1.;
> #P objectname jit.gl.render;
> #P toggle 79 62 20 0;
> #P objectname toggle;
> #P newex 79 88 50 9109513 qmetro 20;
> #P newex 79 110 58 9109513 t b b erase;
> #P window linecount 2;
> #P comment 208 67 228 9109513 when moving the mouse from top left to bottom
> right of the jit.window the angle jumps a fulll rotation.;
> #P connect 31 0 28 0;
> #P connect 33 0 31 0;
> #P connect 29 0 33 0;
> #P fasten 22 0 11 0 353 205 353 205;
> #P fasten 22 0 29 0 353 204 558 204;
> #P fasten 32 0 27 0 521 337 541 337;
> #P fasten 28 0 27 0 558 336 541 336;
> #P fasten 18 0 15 1 353 251 336 251;
> #P connect 18 0 13 0;
> #P connect 11 0 18 0;
> #P connect 4 1 22 0;
> #P fasten 14 0 10 0 319 314 319 314;
> #P connect 15 0 14 0;
> #P connect 17 1 15 0;
> #P fasten 10 0 9 0 319 337 302 337;
> #P fasten 17 0 9 0 302 337 302 337;
> #P connect 16 0 17 0;
> #P fasten 24 0 3 0 191 58 84 58;
> #P connect 24 0 23 0;
> #P connect 21 0 19 0;
> #P connect 20 0 21 0;
> #P fasten 5 1 20 0 213 218 148 218;
> #P connect 1 1 8 0;
> #P fasten 23 0 4 0 191 161 84 161;
> #P fasten 1 2 4 0 132 137 84 137;
> #P connect 1 0 4 0;
> #P fasten 7 0 4 0 145 161 84 161;
> #P fasten 2 0 1 0 84 108 84 108;
> #P connect 3 0 2 0;
> #P connect 6 0 5 0;
>  #P window clipboard copycount 35;
>
>
>
>
> On 10/22/07, Wesley Smith <wesley.hoke at gmail.com> wrote:
> > In polar or cartesian coordinates? I'm not following.  Can you add
> > more info to the question like what your end goal is?  Shortest path
> > is too vague.
> >
> > thanks.
> > wes
> >
> > On 10/22/07, yair reshef <yair99 at gmail.com> wrote:
> > > hi, math question. its hard to formulate as a question, here is a patch
> with
> > > explanation.
> > >
> > > #P window setfont "Sans Serif" 9.;
> > > #P window linecount 1;
> > > #P comment 194 72 130 9109513 how to get the shortest path?;
> > > #P comment 368 194 22 9109513 y x;
> > > #P newex 172 21 45 9109513 loadbang;
> > > #P message 172 127 55 9109513 texture grid;
> > > #P newex 334 170 89 9109513 route screentoworld;
> > > #P message 129 231 91 9109513 screentoworld \$1 \$2;
> > > #P newex 129 207 74 9109513 route mouseidle;
> > > #P newex 129 253 42 9109513 s render;
> > > #P newex 334 215 163 9109513 expr ((atan2($f1 \\\, $f2))/3.1415)*180.;
> > > #P objectname receive[4];
> > > #P newex 283 233 27 9109513 t b b;
> > > #P newex 283 209 33 9109513 r draw;
> > > #P newex 300 256 27 9109513 f 0.;
> > > #P newex 300 278 59 9109513 slide 50. 50.;
> > > #P flonum 334 240 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> > > #P comment 371 240 44 9109513 degrees;
> > > #P message 334 193 31 9109513 \$2 \$1;
> > > #P message 300 303 82 9109513 rotatexyz 0. 0. \$1;
> > > #P window linecount 2;
> > > #P newex 283 328 210 9109513 jit.gl.gridshape rott @color 1 1 1 1 @shape
> > > circle @texture grid @automatic 0;
> > > #P window linecount 1;
> > > #P newex 89 127 35 9109513 s draw;
> > > #P newex 126 127 40 9109513 r render;
> > > #N vpatcher 530 245 771 446;
> > > #P origin 64 -4;
> > > #P window setfont "Sans Serif" 9.;
> > > #P window linecount 1;
> > > #P newex 51 84 40 9109513 sel 0 1;
> > > #P message 51 128 152 9109513 border 1 \, size 320 240 \, pos 10 463;
> > > #P message 66 107 160 9109513 border 0 \, size 1024 778 \, \, pos 1024
> 0;
> > > #P toggle 51 66 15 0;
> > > #P window linecount 0;
> > > #P newex 50 44 35 9109513 sel 27;
> > > #P newex 50 21 40 9109513 key;
> > > #P outlet 56 154 15 0;
> > > #P fasten 1 0 2 0 55 42 55 42;
> > > #P connect 2 0 3 0;
> > > #P connect 3 0 6 0;
> > > #P fasten 6 0 5 0 56 106 56 106;
> > > #P connect 4 0 0 0;
> > > #P connect 5 0 0 0;
> > > #P connect 6 1 4 0;
> > > #P pop;
> > > #P newobj 26 148 25 9109513 p fs;
> > > #P window linecount 2;
> > > #P newex 26 170 178 9109513 jit.window rott @size 320 240 @floating 1
> @pos
> > > 10 450 @idlemouse 1;
> > >  #P objectname jit.window;
> > > #P window linecount 1;
> > > #P newex 65 148 279 9109513 jit.gl.render rott @camera 0 0 3
> @erase_color 0.
> > > 0. 0. 1.;
> > > #P objectname jit.gl.render;
> > > #P toggle 65 48 20 0;
> > > #P objectname toggle;
> > > #P newex 65 74 50 9109513 qmetro 20;
> > > #P newex 65 96 58 9109513 t b b erase;
> > > #P comment 194 53 315 9109513 when moving from top left to bottom right
> the
> > > angle jumps a fulll rotation.;
> > > #P connect 6 0 5 0;
> > > #P fasten 24 0 3 0 177 44 70 44;
> > > #P connect 3 0 2 0;
> > > #P fasten 2 0 1 0 70 94 70 94;
> > > #P fasten 23 0 4 0 177 147 70 147;
> > > #P fasten 1 2 4 0 118 123 70 123;
> > > #P connect 1 0 4 0;
> > > #P fasten 7 0 4 0 131 147 70 147;
> > > #P connect 1 1 8 0;
> > > #P fasten 5 1 20 0 199 204 134 204;
> > > #P connect 20 0 21 0;
> > > #P connect 21 0 19 0;
> > > #P connect 24 0 23 0;
> > > #P connect 16 0 17 0;
> > > #P fasten 10 0 9 0 305 323 288 323;
> > > #P fasten 17 0 9 0 288 323 288 323;
> > > #P connect 17 1 15 0;
> > > #P connect 15 0 14 0;
> > > #P fasten 14 0 10 0 305 300 305 300;
> > > #P fasten 18 0 15 1 339 237 322 237;
> > > #P connect 4 1 22 0;
> > > #P fasten 22 0 11 0 339 196 339 196;
> > > #P connect 11 0 18 0;
> > > #P connect 18 0 13 0;
> > > #P window clipboard copycount 27;
> > >
> > >
> > >
> > > _______________________________________________
> > > jitter mailing list
> > > jitter at cycling74.com
> > > http://www.cycling74.com/mailman/listinfo/jitter
> > >
> > >
> > _______________________________________________
> > jitter mailing list
> > jitter at cycling74.com
> > http://www.cycling74.com/mailman/listinfo/jitter
> >
>
>
> _______________________________________________
> jitter mailing list
> jitter at cycling74.com
> http://www.cycling74.com/mailman/listinfo/jitter
>
>


More information about the jitter mailing list