I'm not new to programming but I'm still new to C# and WPF and I'm somehow stuck.
My problem is: A have a robot-device with several sonar-sensors. Let's assume three sensors for the beginning. One is pointing straight ahead (0°), one is pointing at -15° and the last one at 15°. I'm receiving data from these sensors stating in what distance an object is "seen". That could be interpreted as points with a direction in degrees and a distance. For the beginning I just want to draw lines through these points.
Let's say a have a grid of 500x500 pixel, assuming my device is right at the center-point (250, 250). Drawing lines in certain distances of course is no big deal. But how do I deal with the degree-data?
How do I draw a line that is moved by 15° to the right respectively 15° degrees to the left?
I'm somehow stuck with my ideas and approaches and I'm feeling that I need to be pointed on another better working solution than calculating the desired movement in pixels manually o_O
Many thanks in advance for any ideas! Probably I just don't know about proper transformation- or translation-methods available in C#/WPF?
Greetings,
Andreas
Tomasz KornackiPosted Oct 29, 2010, 4:48 AM
You should apply RotateTransform to your object. RotateTransform instance has properties like Angle (in degrees), CenterX and CenterY, which allows you to customize transformation just as you need. You apply transform by assigning RotateTransform instance to RenderTransform property of the object you want to transform. See below article - it's nice tutorial how to transform objects in WPF:
http://www.codeproject.com/KB/WPF/TransformationsIntro.aspx
Regards
Tomasz