Saturday, January 31, 2015

Plotting Points On A Circle

I once developed a small countdown timer application that used a pie-chart to display the remaining time.  This involved some high school math to be able to plot a line from the center of the circle and plot a radius to specified point on the line.  The same code would also be helpful for developing an application with a compass.

w = width of the space where the circle is bounded
h = height of the space where the circle is bounded
d = diameter (the shorter of w or h)
r = radius = d/2 = SQRT((x2-x1)^2 + (y2-y1)^2)
x1,y1 = circle center
x2,y2 = a point on the circumference
a = angle (from 12:00)
b = modified angle to convert from degrees to radians, reverse direction of unit circle, and start at 12:00 instead of 3:00.
t = total number of segments
s = segment number
a = (360/t) * s = 360 * (s/t)
b = (270 - a) * (Pi / 180)
x2 = x1 + (r * cos(b))
y2 = y1 + (r * sin(b))
x1 = w/2
y1 = h/2

For a space that  has a height of 400 and a width of 648
h = 400, w = 648
d = 400
r = 400/2 = 200
x1 = 648/2 = 324
y1 = 400/2 = 200

In the case of a clock, there are 60 seconds and thus 60 total segments
t = 60

Each second is 1 segment and thus 20 seconds is segment number 20
s = 20
a = (360/60) * 20 = 120
b =  (270 - 120) * (Pi / 180) = 149.9825

x2 = 324 + (200 * cos(149.9825)) = 324 + (200 * -0.5) = 324 + (-100) = 224
y2 = 200 + (200 * sin(149.9825)) = 200 + (200 * 0.866) = 200 + 173.21 = 373.21

In C#.NET, it looks like this:

  int radius = 0;
  double angle = 0;
  lineShape1.X1 = ClientSize.Width / 2;
  lineShape1.Y1 = ClientSize.Height / 2;
  if (lineShape1.X1 < lineShape1.Y1 ) {
      radius = lineShape1.X1;
  }
  else {
      radius = lineShape1.Y1;
  }
  angle =  Convert.ToDouble(360 *
              (Convert.ToDouble(TotalRemaining)
             / Convert.ToDouble(TotalStart)));
  angle = (270 - angle) * (Math.PI / 180);
  lineShape1.X2 = Convert.ToInt32(lineShape1.X1 
                   + (radius * Math.Cos(angle)));
  lineShape1.Y2 = Convert.ToInt32(lineShape1.Y1 
                   + (radius * Math.Sin(angle)));

download exe

download source code



Sunday, January 18, 2015

Step Away From The Ledge

Today I saw a video online where Cenk Uygur was responding to the recent attacks in Paris at the offices of the Charlie Hebdo (Jan 2015).  Cenk described himself as agnostic and he made some good points I would like to recap and respond to.

He asks if God rules the universe, then how likely is he to look down at Earth and respond "Oh no, someone has drawn a negative cartoon about me and my prophets.  I don't know what to do about that.  I sure hope someone defends my honor and gets revenge."

Cenk went on to say that Islam (and other religions) teach that disrespect and/or denial of God and his prophets can lead to eternal pain, suffering, and damnation.  If that is true, then why do offenders need to be killed or punished now?  Isn't it enough that they will suffer for all of eternity?   Compared to that, torture or murder is a walk in the park.

He said that his god is science.  One of the prophets of science is gravity.  The prophet Gravity is not tolerant of disobedience.  If someone where to disrespect Gravity and step off the ledge of a great cliff, there would would be no need to for anyone to defend the honor of Gravity.  No one would need to seek revenge for Gravity.  Upon stepping off the ledge, Gravity would serve his justice swiftly and severely.

Although Cenk may be agnostic, I could not agree with him more.  God does not need me to defend him.  If you deny or dishonor him, that is between you and him.  Those who do not wish to spend eternity with him can spend eternity without him.  In my view, those that reject, ignore, or insult God (however you choose to define that) are indeed headed for a ledge.  I am not injured by such actions.  There is no harm I could do that would be greater than what happens once they leave the ledge.  On the contrary, my compassion for them would lead me to draw them away from the ledge.  I would hope to convince them to stay on solid ground.  I would tell them in caring and compassionate terms about the dangers of the ledge, the wisdom of keeping their distance from it, and the safety and peace that could be found if they would just turn and walk the other way.  The decision would be theirs to make.  I would not (could not) force them to choose the way that I have chosen.  

In short, I would lovingly plead with them to please step away from the ledge.

Saturday, January 10, 2015

Franklin's Whistle

I recently finished listening to Frank Woodworth Pine's edition of Franklin's Autobiography.  I thoroughly enjoyed this book. Franklin seems to have something to say about just about everything.  His "up by his own boot straps" account of his life is fascinating.  The book covers his involvement with writing, printing, politics, government, military campaigns, and science...just to name a few.  I highly recommend it to anyone.  Here are just two sources for the book:
https://librivox.org/the-autobigraphy-of-benjamin-franklin-ed-by-frank-woodworth-pine/
https://books.google.com/books?id=bJIEAAAAYAAJ

At the end of the book, Pine included one of Franklin's letters to Madame Brillon.  An extract from this letter is below which is a good reminder on judgement, financially and otherwise.

Enjoy.

The Whistle
by Benjamin Franklin

When I was a child of seven years old, my friends, on a holiday, filled my pocket with coppers. I went directly to a shop where they sold toys for children; and being charmed with the sound of a whistle, that I met by the way in the hands of another boy, I voluntarily offered and gave all my money for one. I then came home, and went whistling all over the house, much pleased with my whistle, but disturbing all the family. My brothers, and sisters, and cousins, understanding the bargain I had made, told me I had given four times as much for it as it was worth; put me in mind what good things I might have bought with the rest of the money; and laughed at me so much for my folly, that I cried with vexation; and the reflection gave me more chagrin than the whistle gave me pleasure.

This, however, was afterwards of use to me, the impression continuing on my mind; so that often, when I was tempted to buy some unnecessary thing, I said to myself, Don’t give too much for the whistle; and I saved my money.

As I grew up, came into the world, and observed the actions of men, I thought I met with many, very many, who gave too much for the whistle.

When I saw one too ambitious of court favor, sacrificing his time in attendance on levees, his repose, his liberty, his virtue, and perhaps his friends, to attain it, I have said to myself, This man gives too much for his whistle.  

When I saw another fond of popularity, constantly employing himself in political bustles, neglecting his own affairs, and ruining them by that neglect, He pays, indeed, said I, too much for his whistle.  

If I knew a miser, who gave up every kind of comfortable living, all the pleasure of doing good to others, all the esteem of his fellow-citizens, and the joys of benevolent friendship, for the sake of accumulating wealth, Poor man, said I, you pay too much for your whistle.  

When I met with a man of pleasure, sacrificing every laudable improvement of the mind, or of his fortune, to mere corporeal sensations, and ruining his health in their pursuit, Mistaken man, said I, you are providing pain for yourself, instead of pleasure; you give too much for your whistle.  

If I see one fond of appearance, or fine clothes, fine houses, fine furniture, fine equipages, all above his fortune, for which he contracts debts, and ends his career in a prison, Alas! say I, he has paid dear, very dear, for his whistle.

When I see a beautiful sweet-tempered girl married to an ill-natured brute of a husband, What a pity, say I, that she should pay so much for a whistle!  

In short, I conceive that great part of the miseries of mankind are brought upon them by the false estimates they have made of the value of things, and by their giving too much for their whistles.  

Yet I ought to have charity for these unhappy people, when I consider that, with all this wisdom of which I am boasting, there are certain things in the world so tempting, for example, the apples of King John, which happily are not to be bought; for if they were put to sale by auction, I might very easily be led to ruin myself in the purchase, and find that I had once more given too much for the whistle.


Saturday, November 29, 2014

A Theist Conversation


Nov 29, 2014

I have a friend who is an atheist. Her name is Julie Orr and I was very excited when I heard that she had a desire to read the Bible.  Being an atheist, she approached it from an academic / intellectual / anthropological point of view.  It was not her goal to grow closer to God, but rather to learn more about a book that many uneducated people seem to cling to.  I committed to reading it with her in a year (2011) and the emails we exchanged during that year have been compiled into a book that we titled, "A Theist Conversation".


A print copy can be ordered from CreateSpace at https://www.createspace.com/5034385
A Kindle version can be ordered from: http://www.amazon.com/dp/B00Q8WOV40
(it can be also be found on Amazon.com)

Sunday, August 24, 2014

My swiss army knife and me.

Ever since I can remember, I have owned a pocket knife.  I am pretty sure that one of my first knives was a cub scout pocket knife. Not too much unlike this one:

What I would not give to still have that old knife.  It was not long before I graduated to a swiss army knife.  For the uninformed (and any one that has never watched MacGyver), the swiss army knife is a mulit-purpose knife with a large blade and a variety of other tools which usually include a screwdriver and can opener.  In the late 1800's, Switzerland's army began distributing such knives to it's officers - and thus the Swiss Army Knife was born.  Over the years, it's utility and variety of available tools has made it synonymous with versatility.  A coworker was once asked to do a job that was outside his normal skill set and range of responsibility.  He answered, "I am a Swiss Army Knife - I can do anything."  Indeed, the Swiss Army Knife is sometimes lampooned for the variety of functions it can perform.
  
Most everyone knows about the swiss army knife in general, but only the discerning know about the "Original" vs "Genuine" distinction.  Early on, I discovered that the knife's popularity had spawned many cheap imitators.  I also noticed that quality ones had a crossbow (not an umbrella like I thought at first) engraved on the bottom of the main blade.  They would also say "OFFICER SUISSE" and many would have "VICTORIA" engraved on it as well.
I soon learned that this was the mark of a Victorinox and that there was another "real" swiss army knife made by Wenger.

 
It turns out they are both real swiss army knives (but this can be said for only those two brands).  Victorinox is branded as the "Original Swiss Army Knife" and Wenger is the "Genuine Swiss Army Knife".  I gravitated toward Victorinox as the superior brand much the same as Coke is better than Pepsi.  As if the superior design of the Victorinox can opener over the lesser Wenger version was not enough and the fact that Victorinox later aquired Wenger and mercifully allowed them to keep their brand....as if these two facts were not enough, the clincher is that MacGyver used a Victorinox in all but 3 of the 97 episodes where a swiss army knife was employed.  Inconceivable as it sounds, there were 42 episodes where he did not use a knife at all.  It seems that he favored the Spartan.

This brings me to my preferred model.  Boy Scouts and Swiss Army Knives go together like peanut butter and chocolate.  Each is wonderful on their own, but together they are amazing.  I like to carry the Huntsman.

The stock Huntsman has a corkscrew.  The Boy Scouts figured that 12-18 years did not really need to open anything that was hidden behind a cork, so they wisely replaced it with a phillips head screwdriver.  The other two tools that make this model stand out are the saw (what self respecting Boy Scout does not need a saw from time to time) and the scissors.  Ah, the scissors - those glorious scissors.  It is that which inspired me to write today's entry.  Before I get to my scissor story, let me tell you about my Huntsman.

My knife has been put to good use and well tested.  I have used from the backwoods to the front office and everywhere in between.  Some where along the way, I noticed it was getting a little grimy.  What better way to clean it than put it in boiling water to remove all the impurities?  Appearanlty, boiling water considered the glue holding the red plastic covering to the metal to be an impurity - and away it went.  For several years, my poor little knife was half naked.  Red covered on one side and naked on the other.  Finally I restored its dignity and glued the other side back on.  I can easily tell my warped sided little buddy from any other look-alikes.

Back to the scissors.  One of the most frequent uses of my swiss army knife is clipping my fingernails with the scissors.  They just work so much better than any cuticle scissors or fingernail clippers that I have come across.  Over the past couple of weeks, my nails have reached the stage of needing some attention.  My knife occasionally likes to play hide and seek from me and has eluded me for several weeks now.  It does this from time to time but always comes back to me.  This time, however, I was starting to become desperate.  After looking in all my pockets and my gym bag and my car and my bedside, I still could not find it.  If I did not do something soon, I would have to paint my nails.  To quote that great maritime philosopher (Popeye): "I've had all me can stands and me can't stands no more". In desperation I stole borrowed my wife's nail kit.  The clippers just would not give the satisfying "click" sound as they broke through...because they wouldn't break through.  I tried the little scissors.  The just slipped around the nail side ways like a piece paper sliding through children's safety scissors.  Then it hit me.  I had the perfect idea.  I dashed to the closet and pulled out the shoe box.  You know the one.  The one with my grandfather's watch, my set of Superman collecting cards, my Eagle Scout ribbon,  my pinewood derby car, and other such prized possessions.  I opened it up and rummaged through it.  There it was.  The object of my search.  My SwissChamp.  The one my mother had bought for me IN SWITZERLAND when she took me as a 12 year old.  I know the Huntsman will turn up soon.  I am not worried.  But today, the SwissChamp, that 3.5" beauty with all of its 33 various tools, would save the day.  I found the scissors and trimmed my nails to manicured perfection.  My swiss army knife did not let me down...and it never has.


Thursday, August 21, 2014

Mr. Cheerful

If you know much about Atlanta, you know that Interstates 75 and 85 go right through the middle of it.  The two interstates are like two wires wrapped around each other but separated on either end.  The twisted part in the middle is in the heart of Atlanta and is known as "the connector" which runs North and South.  Intersecting perpendicularly, and running East and West,  is Interstate 20.  The convergence of all these interstates creates quite a traffic snarl on most mornings.  Travelling from West to East and then merging North onto the connector can take a quite a while, especially in the mornings.  With all those cars backed up, it has a prime place for the homeless to look for a little good will from the daily commuters.  For the better part of the last 20 years, this is the guy that me and several thousand other commuters would see nearly every day:

Although I never knew his name, I was always fascinated by him.  He was always smiling or waving or saluting.  From what I saw from my car window, he always appeared fresh and clean.  Never dirty or disheveled. His cheerful demeanor was uplifting.  The fact that he was so cheerful despite what must have been difficult circumstances often encouraged me to smile through my own trials.  Just seeing him brightened my day.

Some say you should never give handouts since it is a positive reinforcement and a discouragement for hard work at an honest job.  Other say the homeless are human beings just like you and me and deserve the same respect and occasional helping hand that we would hope to receive.  That is a worthy debate to have, but it is not the purpose of this post.  In fact, on some days I would get in "his" lane so that I could give him a sandwich or a few dollars.  On other days I would get in the right lane just so I would not feel pressured to give him anything.

He is certainly not the only homeless guy in Atlanta.  In fact, in the past few months he was one of three or four in the same small area.  I was forced to do more than a little introspection when I found that it was much easier to turn a blind eye to the unshaven and dirty sad looking guys than to Mr. Clean & Cheerful. What makes it so easy to be drawn to this guy and so easy to look past those around him?  I'm afraid the answer likely reveals a darker part of human nature.

In the past few years, I have discovered a shortcut that would take me on some side streets and get me on to the connector much faster than those that drove past Mr. Cheerful.  Although I would no longer drive past him, I would look across the way just see if he was still over there.  He always was.  Occasionally, I would do Google searches to see if I could find anything out about him.  I thought surely someone else was enthralled with him as I was.  Nothing ever came up.

Last week I happened to go the way of Mr. Cheerful and saw this:

There was no traffic that day, so there was no Mr. Cheerful.  I found the display curious and feared the worst.  A few days later, I went that way on purpose and found a new guy in the same spot.  After giving him a few dollars, I asked him what happened to "that" guy (pointing to the display against wall).  I was told that while he was sleeping in that very spot in his tent, a DUI truck left the road and ran right into him as he slept.  He died on the spot.  A news story confirmed the account.  The memorial showed that I was not the only one that would miss Mr. Cheerful.  I contacted the writer of the news story and learned that the man's name was Johnny Johnson Jr.  I also learned that a group named MOTION had helped Johnny and others for years.  They were the ones that first broke the news of Johnny's death.  Although his obituary was rather brief, the comments were a testament to the fact than there were many people, like me, that were daily encouraged by a complete stranger.  I will miss him even though I never really knew him.  I never knew him by Johnny until after his death. His death is a reminder that each of the homeless are more than just a problem to solve, more than just a beggar - they are a fellow human being with a name - even if we never  know it.


Saturday, March 22, 2014

On the Big Bang

3/22/2014

I was born in 1971 and from childhood was taught about how God created the world (and the universe)  in seven days and many years later instructed Noah to build an ark in preparation for a flood that covered the earth.  From the beginning, I have accepted this as fact.  I have never confused it with the fables of Paul Bunyan, the fantasy of Leprechauns,  or the mythology of Zeus.  God, creation, and the ark were fact while Buynan,  Leprechauns, and Zeus were not.  I later learned that the Easter Bunny and Santa Claus were made up but that never shook my faith in God or the stories of Adam and Eve.

In 1983, I entered 7th grade with Mrs. Vance as my science teacher.  She was reluctantly obligated to tell us about the “theory of evolution” as one of the explanations of the origin of man.  Now at this point I know that some readers are already pounding their fist and shouting “It’s not a theory!  It’s proven fact.”  Nevermind the fact we still refer to the “theory of a relativity” (as opposed to “the principal -or the law- of relativity”).  Also nevermind the fact that Geometry abounds with theories.  It was simply taught to me as the “theory of evolution” from day one.  Mrs. Vance was clearly somewhat skeptical about it and would clearly rather not mention it.   The State of Georgia Public School System, however, felt otherwise.  So I was taught that man came from apes which came from fish which came from a sea on a planet which came from a big explosion (or bang).  The Big Bang was instant and was followed by millions of years of evolution.  It was not long before I accepted gravity and the periodic table of elements as scientific fact and the Big Bang and evolution as … well as something closer to Leprechauns.  Many years later as an adult I watched the 1968 version of “The Planet of the Apes” and thoroughly enjoyed it as fictional entertainment.  My wife, however, would not even watch it because she was raised to be even more dismissive of evolution than I was.  The very idea of apes being humanlike was too close to evolution which was too close to heresy.   In my late teens and early twenties, I saw several shirts, bumper stickers, and the like that said “I believe in the Big Bang theory.  God spoke and ‘Bang’ it happened.”.  This was meant to be a clever play on words that confirmed creationism and denounced the Big Bang.  

I have become increasingly dismayed to see science and religion pitted against each other as adversaries.  Many on both sides treat the two as mutually exclusive.  To me both have their appeal.  Science claims to forever be searching for the truth and willing to discard in an instant any idea that no longer holds water.  Religion claims to already know the truth and to be unshaken by the latest fad theory.    Some fear that too much attention to science breeds a society without morals and leads to abortions on demand.  Others fear that too much attention to religion breeds dogmatic ignorance and leads to the bombing of abortion clinics.  Some say religion is fine for feeding the poor and counseling the grieving, but should stay away from explanations of our origin.  Others say science is fine for creating more fuel efficient cars and curing cancer, but should stay away from explanations of our origin.  I, however, find myself in the middle.  I think the two increasingly support the other.  The only reason I care about creation at all is that it came from the Bible.  In general, the BC part of the Bible is less important to me than the AD part of the Bible.  While I discern a difference between the stories of Zeus as fiction versus the stories of Noah as fact, I do not discern a difference between Adam and Jesus as regards historicity.  Consider the statement: “I am 42 years old and am the President of the United States”.  It is not accurate.  At least not completely.  The fact that I am NOT the President of the United States does not invalidate the the fact that I AM 42 years old.  Many people view the Bible like this.  Part of it (such as the stories of Jesus) is true and part (such as stories of creation) is not.  While that is certainly possible and logical, it is also troubling.  If I were on the witness stand and made the above statement, it might be said that it brings into doubt the credibility of the witness.   In other words, if the Bible is wrong about creation, what else might it be wrong about?  Who is to say which is which?  This is the reason Christians are so adamant about creation.    

During my college years the term “Intelligent Design” began to gain favor over “Creationism”.  This seemed to be a peace offering from the religious side.  It was a way to say there is likely some intelligent force that engineered the universe with intent without having to mention a name for this intelligent force or spell out what thing was created on what day.  It took advantages of verses in the Bible that say that to God one day is like a thousand years (calling into question the 168 hour version of creation) and discounting the need to quibble over young earth or old earth views. It also allowed the religious to embrace (or at least accept) the idea of the Big Bang and still maintain their view of what initiated the bang.  What was once an opposing argument was now a supporting one.  The juxtaposition has continued from then until now.  This was most striking when just a few days ago news broke that a team of astronomers at the South Pole led by John Kovac discovered, through the BICEP2 experiment, ripples of primordial gravitational waves that came from Big Bang itself.  These waves support the idea of cosmic inflation which says the universe went from subatomic size to a trillion trillion times that in less than second.  I almost laughed out loud when I discovered that both science and religion seemed to be shouting “See! I told you so.”.

As for me, I first thought the Big Bang was just myth.  Then I thought it confirmed my religious beliefs.  Now, when I hear about the the Big Bang theory,  I mainly just think of the zany antics of Sheldon Cooper and his friends.