Categories
Latest News
- 200W+50W Bi-Amp Power Section and Crossover Replacement For Advent Powered Speakers.
- Darker Downtime…
- Curiously Strong Power Supply Design
- ATTiny44 Based Shifty VU Meter Controller (MAKE2008)
- Curiously Strong TriAmp Speaker Selection
- Grow LED Array Rev.2 Results AKA Why Rev.3
- Grow LED Array Prototype Rev. 2
- MAKE 2008 Grow LEDs Array Prototype Design
- Stereo Audio IO Landing Pad for Olimex SAM7-H256: Assembled
- Jabra BT125 Bluetooth Headset Teardown
Monthly archives
- October 2008
- September 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- October 2007
- September 2007
Search
“Hello World” is Lame. My First C App, “inthetriangle”.
At some point, it was realized learning C is something that needs to be done before trying out anything ARM core based. Learning on an AVR, after already knowing how to do things competently on the microcontroller in ASM, was frustrating as it for the most part seemed pointless, introducing a whole other layer of issues that came with the compiler and had nothing to do with the hardware itself. Something tiny was written to test the WinAVR installation, then something better to do was found.
Then the other night, a friend came over and said his C class and the instructor didnt have a working algorithm to find if a test point was within a triangle. So I stared for awhile, convinced it didnt take very complex math to figure it out. The algorithm involved calculating the points that a horizontal line passing thru the test point intercepts the triangle sides (using slope equations and a difference equation) and testing if the test point is between these points. I decided I wanted to code my algorithm in C.
So here is the end result. My first C app, inthetriangle, will indicate if a point is on, within, or outside of a triangle. It will also indicate if the triangle points are invalid because of repeated points or if they actually describe a line segment. Input with scanf() is decidely ghetto. I’ll have to change that.
Posted by rmrubin
September 2007