ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

SIMPLE THINGS


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

SIMPLE THINGS

Lessons from the Trenches Prime Numbers Revisited
by George Martin

Start ı Being Ardent ı An Example ı Sources and PDF

BEING ARDENT

What started this line of thinking and prompted me to write was the article "Algorithm Tests for Point Location" by Lawrence Arendt. [1] Arendt presents a simple way to determine if a point lies inside a triangle. I was impressed because I donıt usually come across software engineers who would consider this real-world geometry topic.

Most of us have probably written code for this type of testing. Iıve done it for rectangles and circles. Iıve said to myself, "This problem is trivial; you justı" and then I realized that my approach was like the second software reply from above. Lots of words, but no real substance and a long dark alley. Arendtıs triangle algorithm is a clever solution.

In his article, Arendt explains that, if you have a triangle ABC that has area A, then point X lies inside triangle ABC if the sum of the three triangles formed by point X and the three vertices equals the area A. So, if Area (ABX) + Area (AXC) + Area (XBC) = Area (ABC), then point X is inside triangle ABC. Draw yourself a picture and it should become clear.

Arendt used C++ to design and code his algorithm. I read that and was going to tell you how it would be much simpler to design and code in plain old C. So, I started to design and code a simpler version. To my surprise, I could do the design and coding in C, but it was not simpler.

The truth is that, in my original draft of this article, I went on to explain why C++ provided a better solution. I submitted it and then got an e-mail from Circuit Cellar Project Editor Dave Tweed (whose day job, ironically enough, is hardware engineering), who had proofread my manuscript. He showed me a simple C routine that was equivalent to the original C++ routine. Needless to say, I was flabbergasted that someone could come up with a solution that I couldnıt find.

Think again about seeking out the hardware experts for a good solution. I need to modify my observations and tell you that you may be surprised where you can get a clearer way of looking at your design problem. Be open to input from all sources, but be careful to weed out the signal from the noise.

PREVIOUSNEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ıCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ