Yet another blog about WPF, Surface, SL, MVVM, NUI.... - MultiTouch - Comments In this blog we talk about WPF, Natural User Interface(NUI), Microsoft Surface, WIndows 7, Multitouch, Touchless, JavaFX, MVVM, patterns, tips, tricks .... and a lot of other things ! 2024-02-26T15:40:43+01:00 Jonathan ANTOINE urn:md5:627146f22bec1346990949372a159bfa Dotclear How to scale around a specific point and not the center of the Element - Martin Berger urn:md5:04a3699214e5c1fb97a23dd70599030a 2012-12-07T10:20:03+01:00 2013-02-28T15:28:31+01:00 Martin Berger <p>Hello,</p> <p>what is this last line supposed to perform?</p> <pre> if (scaleDelta &gt; 1.0) _myObjectToScale.Center += new Vector(newCenterXD, newCenterYD); else _myObjectToScale.Center += new Vector(newCenterXD, newCenterYD);</pre> <p>scaleDelta can be less or greater that 1.0, same code will execute.</p> Calculate the real difference between two angles, keeping the correct sign - AlexL urn:md5:3acb23ecf73534a53ce14f51bab20096 2012-10-22T00:06:35+02:00 2013-02-28T15:28:31+01:00 AlexL <p>Thanks, this helped me out big time!</p> Calculate the real difference between two angles, keeping the correct sign - JonathanANTOINE@falsemail.com urn:md5:a79c6c1e6fe66c9b485cb1c572e7f01f 2012-04-06T09:02:50+02:00 2012-04-06T09:02:56+02:00 JonathanANTOINE@falsemail.com <p>Cool !</p> Calculate the real difference between two angles, keeping the correct sign - tigrou urn:md5:448db09b9bfe1cf48764bf68f7a0dffe 2012-01-12T13:18:30+01:00 2012-04-06T09:02:56+02:00 tigrou <p>Perfect ! just what i was looking for. Tested and works successfully !</p> Calculate the real difference between two angles, keeping the correct sign - RNH urn:md5:488f8700ec7634b244e273bddcb68720 2011-05-04T04:31:45+02:00 2012-04-06T09:02:56+02:00 RNH <p>If you only want to know the absolute difference then you can use<br /> DEL = PI - ABS(PI - ABS(A - B)) in radians.<br /> DEL = 180 - ABS(180- ABS(A - B)) in degrees.</p> Calculate the real difference between two angles, keeping the correct sign - marco polo urn:md5:761d4a9cbd304434f048d39277d3ecc5 2011-04-28T22:09:55+02:00 2012-04-06T09:02:57+02:00 marco polo <p>try this..</p> <pre> private static double GetPositiveAngle(double radian) { if (radian &lt; 0) radian = (Math.PI * 2) - Math.Abs(radian); return radian; }</pre> <pre> public static double GetAngleDifference(double angle1, double angle2) { var rslt1 = GetPositiveAngle(angle1); var rslt2 = GetPositiveAngle(angle2); if (rslt2 &lt; rslt1) rslt2 += 2 * Math.PI; return rslt2 - rslt1; }</pre> Calculate the real difference between two angles, keeping the correct sign - AronT urn:md5:819c641b2fd9fc2efdb134e1a7ed178e 2011-04-24T16:42:33+02:00 2012-04-06T09:02:57+02:00 AronT <p>A snippet of code taken from my archive in Blitz3D that was used to turn a missile towards the player</p> <p>It eliminates the need to use mod<br /> Will work with angles of any size<br /> Returns an angle in the range -180 to 180<br /> (<br /> diffangle = (actualangle - destangle) + 180;<br /> diffangle = (diffangle / 360.0)<br /> diffangle = ((diffangle - Floor( diffangle )) * 360.0) - 180;<br /> )<br /> !Notes: The Floor command takes the float number and rounds it down to the nearest whole number!</p> Calculate the real difference between two angles, keeping the correct sign - Alan urn:md5:09a46b577ff2609834813e3dde8a8605 2011-04-08T12:09:28+02:00 2012-04-06T09:02:57+02:00 Alan <p>I use:</p> <p>differenceAngle = (targetAngle - currentAngle) % 360.</p> <p>this gives you the angle of the target relative to current angle, and is positive for a clockwise rotation.</p> How to create an hand writing to text control (ink recognizer) - Abdo urn:md5:4335a166eda7d5baca20f21541a7cd7f 2010-10-25T13:30:50+02:00 2010-10-26T09:53:47+02:00 Abdo <p>Nice One , Thanks man.</p> How to scale around a specific point and not the center of the Element - Jonathan ANTOINE urn:md5:dfdec9d2aceddbf64380ec872efd8b65 2010-06-05T17:16:00+02:00 2010-06-05T17:16:43+02:00 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2009/10/11/How-to-scale-around-a-specific-point-and-not-the-center-of-the-Element#c2019" rel="nofollow">Jack A</a>:Hello, You may put the IsHitTestVisible property to false ?</p> How to scale around a specific point and not the center of the Element - Jack A urn:md5:868bcaa646412c5c8f917b7fa492c10a 2010-06-05T14:19:27+02:00 2010-06-05T17:15:55+02:00 Jack A <p>This is a really great article.</p> <p>I would like to be able to prevent a scatterviewitem from continuing to manipulate after I have removed all contacts from it. In other words I would like to prevent an item from being thrown across the screen, but simply want it to stop at my last point of contact. None of the scatterviewitem methods, properties and events seem to offer this capability. Do you know if this is possible?</p> Calculate the real difference between two angles, keeping the correct sign - René urn:md5:3e73f1878870dd28bc6665ad0f03a5fa 2010-04-27T15:55:23+02:00 2012-04-06T09:02:57+02:00 René <p>@Rich</p> <p>350 - 10 = 340 &gt; 180 =&gt; 340 - 360 = -20</p> Calculate the real difference between two angles, keeping the correct sign - Rich urn:md5:fae8c05345cc4f203bb3d836db7e9403 2010-03-29T21:02:10+02:00 2012-04-06T09:02:57+02:00 Rich <p>@tk is superior as the sign can interpret the direction of rotation. Jon's method doesn't work in some cases, say 10 degrees to 350 reports 20 degree turn, not -20 degree...</p> Calculate the real difference between two angles, keeping the correct sign - Liz urn:md5:553186f18830d4f4530b7939ee403da2 2010-01-22T11:17:52+01:00 2012-04-06T09:02:57+02:00 Liz <p>@tk : That's so elegant - thank you, just what I needed :o)</p> Calculate the real difference between two angles, keeping the correct sign - Jonathan ANTOINE urn:md5:faa4599cdc1655d18ed1fc46b21139a3 2009-11-28T23:49:29+01:00 2012-04-06T09:02:57+02:00 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/Calculate-the-real-difference-between-two-angles-keeping-the-sign#c774" rel="nofollow">tk</a> :I simply do it to have the right result : the angle can be more than 360° (suppose you have done 2 turns)....</p> <p>Your solution may works too... </p> Calculate the real difference between two angles, keeping the correct sign - tk urn:md5:3fe3cd3680c5c9e2ffec29417b68fb64 2009-11-28T22:40:40+01:00 2012-04-06T09:02:57+02:00 tk <p>I was wondering two things: why do you use while instead of if, is that C#? and, perhaps, could you do<br /> double difference = mod( secondAngle - firstAngle + 180, 360 ) - 180;<br /> I suppose it depends on the compiler or deeper knowledge of the computer to know which is faster.</p> Calculate the real difference between two angles, keeping the correct sign - Aubrey urn:md5:11f448175a1121878726b7c8df165dc9 2009-11-07T12:43:34+01:00 2012-04-06T09:02:57+02:00 Aubrey <p>Yep. We use this where I work (and in my homebrew). We call it "Normalize180", and there's a variant called "Normalize360", which does the same thing, but in the range 0f&lt;a&lt;360f.</p> <p>You could also divide the difference by 180.0f, then take only the fractional part of that (behind the '.' ) and multiply it by 180, making sure to maintain the sign.</p> <p>i.e.<br /> float NormalizedAngle = diff / 180.0f;<br /> if(diff &gt; 0){<br /> return (NormalizedAngle - Math.Floor(NormalizedAngle)) * 180.0f;<br /> } else {<br /> return (( NormalizedAngle - ( Math.Floor(NormalizedAngle) + 1.0f ) * 180.0f );//Errr... not sure about this bit - have to deal with negative case. Might be a better way to get the fractional part than number minus floor(number)<br /> }</p> <p>That would probably be less cycles than a while loop, but typical input numbers are unlikely to be high, so your approach is probably fine in most cases.</p> [ping] How to scale around a specific point and not the center of the Element - DotNetShoutout urn:md5:d78c56a1c8d0572d2b90b453fe640ac2 2009-10-11T18:37:02+02:00 2009-10-11T18:37:02+02:00 DotNetShoutout <p><a href="http://dotnetshoutout.com/How-to-scale-around-a-specific-point-and-not-the-center-of-the-Element">How to scale around a specific point and not the center of</a></p> <!-- TB --> <p>Thank you for submitting this cool story - Trackback from DotNetShoutout...</p> [ping] How to scale around a specific point and not the center of the Element - DotNetKicks.com urn:md5:a1e44278e41aeefd0dc72824ea31569c 2009-10-11T18:22:13+02:00 2009-10-11T18:22:13+02:00 DotNetKicks.com <p><a href="http://www.dotnetkicks.com/tipsandtricks/How_to_scale_around_a_specific_point_and_not_the_center_of_the_Element">How to scale around a specific point and not the center of</a></p> <!-- TB --> <p>You've been kicked (a good thing) - Trackback from DotNetKicks.com...</p> Calculate the real difference between two angles, keeping the correct sign - Peter urn:md5:bc3ed1c70c6cadede7eceb80d70f8020 2009-10-04T21:21:30+02:00 2012-04-06T09:02:57+02:00 Peter <p>You saved my day <img src="themes/default/smilies/wink.png" alt=";-)" class="smiley" /></p>