Yet another blog about WPF, Surface, SL, MVVM, NUI.... - MultiTouch - CommentsIn 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:00Jonathan ANTOINEurn:md5:627146f22bec1346990949372a159bfaDotclearHow to scale around a specific point and not the center of the Element - Martin Bergerurn:md5:04a3699214e5c1fb97a23dd70599030a2012-12-07T10:20:03+01:002013-02-28T15:28:31+01:00Martin Berger<p>Hello,</p>
<p>what is this last line supposed to perform?</p>
<pre> if (scaleDelta > 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 - AlexLurn:md5:3acb23ecf73534a53ce14f51bab200962012-10-22T00:06:35+02:002013-02-28T15:28:31+01:00AlexL<p>Thanks, this helped me out big time!</p>Calculate the real difference between two angles, keeping the correct sign - JonathanANTOINE@falsemail.comurn:md5:a79c6c1e6fe66c9b485cb1c572e7f01f2012-04-06T09:02:50+02:002012-04-06T09:02:56+02:00JonathanANTOINE@falsemail.com<p>Cool !</p>Calculate the real difference between two angles, keeping the correct sign - tigrouurn:md5:448db09b9bfe1cf48764bf68f7a0dffe2012-01-12T13:18:30+01:002012-04-06T09:02:56+02:00tigrou<p>Perfect ! just what i was looking for. Tested and works successfully !</p>Calculate the real difference between two angles, keeping the correct sign - RNHurn:md5:488f8700ec7634b244e273bddcb687202011-05-04T04:31:45+02:002012-04-06T09:02:56+02:00RNH<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 polourn:md5:761d4a9cbd304434f048d39277d3ecc52011-04-28T22:09:55+02:002012-04-06T09:02:57+02:00marco polo<p>try this..</p>
<pre> private static double GetPositiveAngle(double radian)
{
if (radian < 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 < rslt1)
rslt2 += 2 * Math.PI;
return rslt2 - rslt1;
}</pre>Calculate the real difference between two angles, keeping the correct sign - AronTurn:md5:819c641b2fd9fc2efdb134e1a7ed178e2011-04-24T16:42:33+02:002012-04-06T09:02:57+02:00AronT<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 - Alanurn:md5:09a46b577ff2609834813e3dde8a86052011-04-08T12:09:28+02:002012-04-06T09:02:57+02:00Alan<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) - Abdourn:md5:4335a166eda7d5baca20f21541a7cd7f2010-10-25T13:30:50+02:002010-10-26T09:53:47+02:00Abdo<p>Nice One , Thanks man.</p>How to scale around a specific point and not the center of the Element - Jonathan ANTOINEurn:md5:dfdec9d2aceddbf64380ec872efd8b652010-06-05T17:16:00+02:002010-06-05T17:16:43+02:00Jonathan 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 Aurn:md5:868bcaa646412c5c8f917b7fa492c10a2010-06-05T14:19:27+02:002010-06-05T17:15:55+02:00Jack 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:3e73f1878870dd28bc6665ad0f03a5fa2010-04-27T15:55:23+02:002012-04-06T09:02:57+02:00René<p>@Rich</p>
<p>350 - 10 = 340 > 180 => 340 - 360 = -20</p>Calculate the real difference between two angles, keeping the correct sign - Richurn:md5:fae8c05345cc4f203bb3d836db7e94032010-03-29T21:02:10+02:002012-04-06T09:02:57+02:00Rich<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 - Lizurn:md5:553186f18830d4f4530b7939ee403da22010-01-22T11:17:52+01:002012-04-06T09:02:57+02:00Liz<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 ANTOINEurn:md5:faa4599cdc1655d18ed1fc46b21139a32009-11-28T23:49:29+01:002012-04-06T09:02:57+02:00Jonathan 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 - tkurn:md5:3fe3cd3680c5c9e2ffec29417b68fb642009-11-28T22:40:40+01:002012-04-06T09:02:57+02:00tk<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 - Aubreyurn:md5:11f448175a1121878726b7c8df165dc92009-11-07T12:43:34+01:002012-04-06T09:02:57+02:00Aubrey<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<a<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 > 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 - DotNetShoutouturn:md5:d78c56a1c8d0572d2b90b453fe640ac22009-10-11T18:37:02+02:002009-10-11T18:37:02+02:00DotNetShoutout<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.comurn:md5:a1e44278e41aeefd0dc72824ea31569c2009-10-11T18:22:13+02:002009-10-11T18:22:13+02:00DotNetKicks.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 - Peterurn:md5:bc3ed1c70c6cadede7eceb80d70f80202009-10-04T21:21:30+02:002012-04-06T09:02:57+02:00Peter<p>You saved my day <img src="themes/default/smilies/wink.png" alt=";-)" class="smiley" /></p>