The ability to process triangles quickly is important in computer graphics, since complex 3D objects are typically drawn as a collection of small triangles. The surface area of a 3D object can be approximated by summing the surface areas of all the triangles used to define it.
For a triangle with edge-lengths a, b, and c, the area of the triangle can be computed using Heron's Formula:
area = sqrt(p * (p-a) * (p-b) * (p-c) )where p is half the triangle's perimeter: (a+b+c)/2.
The directory
/home/cs/214/projects/12/numbers/contains input files (e.g., 5triangles.txt, 1000000triangles.txt) that have the following format:
This exercise is to solve this problem in each of our four languages, using multithreading to compute totalArea as quickly as you can in each language, using your programs from Lab 12 as models.
Start by writing a version of each program that solves the problem sequentially. When you have it debugged, "parallelize" step 8 of that program using an approach similar to what we did in the lab.
Testing. The directory /home/cs/214/projects/12/numbers/ contains a file 5triangles.txt that you can use to test your programs.
Due Date: April 20. Turn in as much as you have completed by 11:59pm. No submissions of any labs or projects will be accepted after that, to give the graders time to grade before final exams begin.
Turn in. Using an approach like what we did in the lab, make a single script file named proj12-results, in which you list each program, show that it builds without any syntax errors or warnings, and demonstrate that it correctly processes the 'triangles' in the file /home/cs/214/projects/12/numbers/1000000triangles.txt, using 1 thread and 4 threads. Then submit your project by copying that single script file into your personal folder in /home/cs/214/current/:
cp proj12-results /home/cs/214/current/yourUserName
replacing yourUserName with your login name.
The grader will access and grade your project results from there,
using the criteria from
this grade sheet.
Calvin > CS > 214 > Projects > 12