1.Write a Slicer
One of the key steps in processing an STL file for printing is slicing. STL files were written
s were written to make slicing a low memory task by storing each triangle at a single place.
We already have code to do the following:
A Generator that returns a triangle one at a time from an STL file (specifically an ASCII STL file). It Return the triangle as a list of 3D points (tuples), ignoring the normal. (from HW4)
A function that takes a list of line segments, each line segment is a list of 2D points (tuples) and returns a single list of 2D points where the start of one segment is the end of another. ( from HW 3)
A function that converts a list of 2D points to G-Code (lab 2)
A function that writes GCode to a file
To make a slicer you need to:
Write a function that calculates the intersection of a triangle with a horizontal plane. The input of the function should be a list of 3D points (tuples). It should return a list of 3D points. See this website for hints on the mathematics http://geomalgorithms.com/a06-_intersect-2.html#Triangle-Plane (Links to an external site.)
( https://web.archive.org/web/20180706054857/http://geomalgorithms.com/a06-_intersect-2.html (Links to an external site.) )
Next you need to combine all of these different functions into a single workflow that takes in an STL file, a slicing height, print temperatures, movement speed , and extrusion speed and returns a G-code String which prints the walls of the STL file. It should have an outer iteration over slice heights of the STL, for each slice height, it should scan all triangles and make a list of the line segments that intersect the plane at that Z height. Then it should order those segments into a list of points. That list of points is then converted into gcode movement and extrusion commands. The entire system combines these slices with setup and shutdown Gcode for the ender 3 printer to make the print job. You may write to a file a layer at a time or at the end.
Once the slicer is done:
Run the previous function with a vase file such as one of the following files:
Submit your code as a Jupiter notebook with the .gcode in it and, and an image of your print.
2.1. Complete an algorithm, code and compile the following program. Save the program as finalgrade.py.
Final Grade Calculator
Write a program that
Final Grade Calculator
Write a program that allows an instructor to calculate the final grade for the students in a class. Use the following menu to drive the program:
1. Enter new student information
When the user chooses (1) they will be prompted for the following information:
Number of Exams and the grade for each
Number of Quizzes and the grade for each
Number of Homework assignments and the grade for each
Input validation: All grades entered must be between 0 and 100.
The final grade is then calculated as follows:
Exams: 40% of final grade
Display the final grade for each student. The user may enter as many students as possible until they choose to quit.
Please see attached output example.
2. Upload both your algorithm and your source code.
Grading Rubric: (20 points)
Include the following in your algorithm:
Algorithm (3 points)
If statements/Loops (8 points total)
Main menu loop and if statements (4)
Input validation loop for exam, quizzes, homework grade (2)
Input validation for main menu (2)
Calculations (9 points total)
Average exams (2)
Average quizzes (2)
Average homework (2)
Final Grade (3)
3.Implement using a Visual Studio Unit Test Project the test case [amount = $100,000, length = 30 years, interest rate
s, interest rate = 5%] against this function:
public static double PMT(double yearlyInterestRate, int totalNumberOfMonths, double loanAmount)
var rate = (double)yearlyInterestRate / 100 / 12;
var denominator = Math.Pow((1 + rate), totalNumberOfMonths) - 1;
return (rate + (rate / denominator)) * loanAmount;
Note that the expected value for this input is a positive number between $100 and $2000. When using the website to calculate the expected value make sure you zero out all the other components (i.e. the home owner insurance)
5.Ken and Terry’s buys Swiss chocolate directly from Switzerland for the chocolate chunks in all their ice cream. At
ir ice cream. At the current exchange rate of .989 USD to 1 Swiss franc (CHF), the cost of chocolate in francs of ₣40,317,492 comes to $39,874,000. Variations in the exchange rate will affect Ken and Terry’s earnings before tax.
a. Assume no hedge is undertaken and exchange rates may take the values of .969, .989. 1.009, and 1.029. What will be the impact on Ken and Terry’s earnings before tax with each exchange rate? (6 points)
b. You suggest a call option with a strike price of .989 and a call premium of 2.35%. Show how this will affect Ken and Terry’s cash flows. (6 points)
c. Another option is to enter into a forward contract at a forward offer rate of .999. How will this affect Ken and Terry’s cash flows? (5 points)
d. Do you recommend the call option or the forward contract? Explain. (3 points)
4. Ken and Terry’s would like to undertake a corporate value-at-risk calculation based on two risk factors of cream and chocolate. They estimate the following “returns” on these inputs by the mark-up on their finished product relative to input prices. Cream is more prevalent than chocolate; it makes up 80% of the mark-up while chocolate makes up 20%. Other data they have gathered is as follows:
Cream: expected return = 30%
variance of return = .10
Chocolate: expected return = 20%
variance of return = .06
covariance of cream and chocolate = .04
What is the largest decrease in return that Ken and Terry can expect with 99% confidence?