Saturday, January 11, 2014

The Secret Life of Bloggers Blog Party: Post 1

My lovely Stephanie Ann at World Turn'd Upside Down is hosting The Secret Life of Bloggers blog party.  The premise for this is that every day you keep a short log of something you did, and take a picture of it.  Every week you share the pictures and a .  It was difficult to get started this week..I found it hard to get into the routine of carrying my camera or getting my iPod when there was something worthy of a story, but I did my best, and here's what I came up with.

1-3-14

 

Shoveled snow.  Had a good bit of snow the previous night into the next morning.  I did the neighbors' sidewalk as well because if we're all at work they normally help us out.


1-5-14


 Created a work space for myself.  I have my main computer on another desk, but it doesn't really facilitate spreading out my work, so I reallocated this space.

1-10-14

 Hung out with my oldest friend.  My iPod wasn't handy, so I asked him to take a picture on his phone and send it to me.  I think he forgot. :)

1-11-14

 Took two pictures to make up for the lack of during the rest of the week.  It was really cold last night, and Coal cuddled all night.  He was still cold so I covered him up while I was getting ready for work.


It rained all day.  This is the last of the snow from the last storm.  I thought the stream of water in the gutter was really cool going under the little bridge of ice.


It may be a little while until my next post.  My current homework assignment requires a bit of trigonometric knowledge, and I've long since forgotten what I learned in high school years ago.  I've been trying to rapidly relearn what I need to complete the program, but I'm going to continue learning, because it seems like it'd be good to know, and I have been feeling really good about learning things again.

Tuesday, January 7, 2014

A lot of work!

Many people think of coding as just typing a few lines of text into a computer and the job being done.  I knew so many kids when I was young that wanted to learn to make video games, thinking it would be the best job in the world.

What they never realized is how much work goes into a program.  I've only been programming a few weeks, and the programs I'm writing are still very small and impractical, but I'm sometimes amazed at how many steps it takes to do something that seems fairly simple.

One of my homework assignments recently asked me to write a program that calculates the distance between several points in 3D space using a function.  The thing I thought was interesting was the way you have to calculate the formula.

The formula to calculate the distance between the two points is:

This doesn't seem terribly complicated, and it really isn't, but the computer needs you to tell it how to solve the problem, step by step.  You can't just plug this in and expect the computer to know what to do.

The first thing I did was create the function, with 6 floating point parameters named after the variables in the formula.

float Distance(float ux, float uy, float uz,
 float vx, float vy, float vz)


The next step is to create 3 more variables to store the calculations from the subtractions inside the square root.  I initialized each of them immediately to be equal to the square of each subtraction.

 float x = powf(ux - vx, 2);
 float y = powf(uy - vy, 2);
 float z = powf(uz - vz, 2);


Finally I can create another variable to hold the total.  I initialize it to hold the square root of the sum of variables x, y, and z, and tell the function to return the result.

    float distance = sqrt(x + y + z);
    return distance;


Now we are ready to call the function in the program.  When you call the function, you'll give the program the numbers to use.  The order in which you type them is very important, or else the calculations will be off.

 cout << "The distance between (1, 2, 3,) and (0, 0, 0) = " << Distance(1, 2, 3, 0, 0, 0);
 cout << endl;

The entire program:

// 3D Distance
// Calculates the distance between two points in 3D space

#include 
#include 
using namespace std;

float Distance(float ux, float uy, float uz,
 float vx, float vy, float vz);

int main()
{
 cout << "The distance between (1, 2, 3,) and (0, 0, 0) = " << Distance(1, 2, 3, 0, 0, 0);
 cout << endl;

 cout << "The distance between (1, 2, 3,) and (1, 2, 3) = " << Distance(1, 2, 3, 1, 2, 3);
 cout << endl;
 
 cout << "The distance between (1, 2, 3) and (7, -4, 5) = " << Distance(1, 2, 3, 7, -4, 5);
 cout << endl;
}


float Distance(float ux, float uy, float uz,
 float vx, float vy, float vz)
{
 float x = powf(ux - vx, 2);
 float y = powf(uy - vy, 2);
 float z = powf(uz - vz, 2);

 float distance = sqrt(x + y + z);
 return distance;
}

Sunday, January 5, 2014

The beginning...

My name is Andy.  A few months ago I decided to start learning some HTML and CSS.  Soon after, I started to learn some Javascript..  I started getting really confused after a few lessons, and started looking into some other books to help me out.  At that point, I remembered always wanting to learn to program applications when I was younger, so I did some research and decided to learn C++.

 So now I've got a few books, and I'm taking a sort of online self-guided course.  I decided to write the blog to help keep me on track, and to keep track of my progress.  One day I hope to be good enough to start writing my own programs.  Maybe one day I'll be able to do it for a living.

I know it's going to be a lot of hard work, but so far I've been really enjoying the challenges.  I'll be writing a post on what I'm working on in the next few days.

Thanks for reading!