CSCI 107 Assignment 5
- Due Date: Friday, March 10th no later than 11:59 p.m.
- Partner Information: You may complete this assignment individually or
with exactly one classmate.
- Submission Instructions (working alone): Upload your solution,
entitled YourFirstName-YourLastName-Assignment5.py
to the BrightSpace Assignment 5 Dropbox.
- Submission Instructions (working with exactly one classmate): Upload your solution, entitled
YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Assignment5.py
to the BrightSpace Assignment 5 Dropbox. Note: If you work with a
partner, only one person needs to submit a solution. If you both
submit a solution, the submission that will be graded is the one from
the partner whose last name comes alphabetically first.
- Deadline Reminder: Once the submission deadline passes, BrightSpace
will no longer accept your submission and you will no longer be able
to earn credit. Thus, if you are not able to fully complete the
assignment, submit whatever you have before the deadline so that
partial credit can be earned.
Problem: Determine Distance of Robot Arm Movement
When working with robots, it is often important to know how
far apart two points in 3-dimensional space are so that the time
to move a robot arm can be estimated.
A
formula on this page shows how to calculate
the distance between two 3-dimensional points.
For this assignment, points in 3-dimensions will be identified by
(1) their octant, (2) their x value, (3) their y value and (4) their z value.
Because the octant is given, the x, y and z values will always be
positive. The octants are as follows:
- Octant 1: x ≥ 0, y ≥ 0, z ≥ 0
- Octant 2: x ≥ 0, y ≥ 0, z < 0
- Octant 3: x ≥ 0, y < 0, z ≥ 0
- Octant 4: x ≥ 0, y < 0, z < 0
- Octant 5: x < 0, y ≥ 0, z ≥ 0
- Octant 6: x < 0, y ≥ 0, z < 0
- Octant 7: x < 0, y < 0, z ≥ 0
- Octant 8: x < 0, y < 0, z < 0
Learning Outcomes
- Gain experience writing Python selection statements.
- Gain experience writing a Python function.
Assignment
- Download robot-arm.py and rename
it according to the instructions above.
- Modify the program by replacing the pass command in
the calculate_distance function with the necessary python statements.
This function will use Python selection statements
to calculate and then print the distance between two 3-dimensional points.
If calculate_distance
is implemented correctly, this output
will appear.
Grading - 100 points
- 64 points - Your program will be tested on 8 test cases
that are different than the ones in the provided code.
Solving each test case correctly is worth 8 points
(all or nothing).
- 15 points - The calculate_distance function uses if statements
economically (5 points for each type of improvement
that is identified).
- 10 points - Appropriate comments are added to your solution
(5 points for each type of comment that is missing).
- 11 points - The output format of the output transcript is
matched exactly (3 points for each type of difference).
Test Data with Expected Output
def test_suite():
calculate_distance(1, 5, 10, 15, 1, 5, 10, 15)
calculate_distance(1, 5, 10, 15, 2, 5, 10, 15)
calculate_distance(1, 5, 10, 15, 3, 5, 10, 15)
calculate_distance(1, 5, 10, 15, 4, 5, 10, 15)
calculate_distance(1, 5, 10, 15, 5, 5, 10, 15)
calculate_distance(1, 5, 10, 15, 6, 5, 10, 15)
calculate_distance(7, 5, 10, 15, 1, 5, 10, 15)
calculate_distance(8, 5, 10, 15, 1, 5, 10, 15)
The correct output is
Distance from (5,10,15) to (5,10,15) = 0.00 units
Distance from (5,10,15) to (5,10,-15) = 30.00 units
Distance from (5,10,15) to (5,-10,15) = 20.00 units
Distance from (5,10,15) to (5,-10,-15) = 36.06 units
Distance from (5,10,15) to (-5,10,15) = 10.00 units
Distance from (5,10,15) to (-5,10,-15) = 31.62 units
Distance from (-5,-10,15) to (5,10,15) = 22.36 units
Distance from (-5,-10,-15) to (5,10,15) = 37.42 units