This is our first coding project of the year. The purpose is to get us used to coding and some of the rules of coding. Please ask questions, I know this is new and probably confusing. We will be using the code below and sharing a link to turn in the assignment.
Look at the code above. It is mostly filled out, but there are a few parts that are missing. Scroll to the right of the code and you should see comments (instructions after a #) to tell you what you need to do for each line of missing code
The final code should have a purple sphere in the bottom right, a red sphere on the top, and a blue sphere on the bottom left. There should be a purple arrow pointing from the purple sphere to the red sphere, a red arrow pointing from the red sphere to the blue sphere and a blue arrow pointing from the blue sphere to the purple sphere. When you are done, you can hit the menu button in the top left of the code and scroll down to share. You will copy this link and turn it in on the Google Classroom. If you need a reminder for how to do this, watch this video.
You can reference a certain part of an object writing the name of the object, then adding a period, and then writing down what you part of the object that you want to reference
On line 1 of the code above, a sphere is created named BlueSphere at the position (3,0,0). On line 3, an arrow is created named Arrow1. The position of Arrow1 is said to be at BlueSphere.pos. What this means is that the position of Arrow1 will be at the position of BlueSphere, so Arrow1 will begin at the position (3,0,0) as well.
You can learn more about dot notation here
To find the difference between two points (in physics and coding) we will use the following formula:
change in position = final position - initial position
To do this with our arrow, we will have to subtract the final position of the arrow by the initial position of the arrow
On line 1 in the code above, a sphere named BlueSphere is created at the position (1,0,0) and is given the color blue. On line 2, a sphere named GreenSphere is created at (0,4,0) and is given the color green. On line 4, an arrow is created and is named Arrow1. This arrow's position is set to BlueSphere.pos which means the arrow will start at the position of BlueSphere. The axis of the arrow is the direction the arrow will face. We have to use the formula for change in position for the arrow to point at the GreenSphere. The code for this is GreenSphere.pos (final position of the arrow) - BlueSphere.pos (initial or starting position of the arrow. This will make the arrow point from the BlueSphere to the GreenSphere like in the picture above