T v1 v2 v3

This preview shows page 5 - 6 out of 6 pages.

\t"); v1 = Integer.parseInt(strtok.nextToken()); v2 = Integer.parseInt(strtok.nextToken()); v3 = Integer.parseInt(strtok.nextToken()); triangles[i]=new int[] {v1,v2,v3}; } } catch (FileNotFoundException e) { e.printStackTrace(); } } public void bigger(){ //scale = scale*1.5; for (int i = 0; i< numOfVertices; i++) { vertices2[i][0] = vertices2[i][0]*1.5; vertices2[i][1] = vertices2[i][1]*1.5; vertices2[i][2] = vertices2[i][2]*1.5; } } public void smaller(){ //scale = scale*0.9; for (int i = 0; i< numOfVertices; i++) { vertices2[i][0] = vertices2[i][0]*0.9; vertices2[i][1] = vertices2[i][1]*0.9; vertices2[i][2] = vertices2[i][2]*0.9; } } public void backFaceCulling(){ numFront = 0; double normalZ; for (int i = 0; i< numT; i++) {
Image of page 5

Subscribe to view the full document.

double[] v1 = vertices2[triangles[i][0]-1]; double[] v2 = vertices2[triangles[i][1]-1]; double[] v3 = vertices2[triangles[i][2]-1]; u = new double[]{v1[0]-v2[0], v1[1]-v2[1]}; v = new double[]{v2[0]-v3[0], v2[1]-v3[1]}; normalZ = u[0] * v[1] - u[1] * v[0]; if (normalZ>=0){ visibleT[i] = invisibleT; } else { visibleT[i] = triangles[i]; numFront = numFront + 1; } } } public void drawModel(){ drawVertices =new int[numOfVertices][2]; for (int i = 0; i< numOfVertices; i++){ drawVertices[i][0] = (int)Math.round(vertices2[i][0]*80); drawVertices[i][1] = (int)Math.round(vertices2[i][1]*80); } } public void sortByDepth(){ sortedT = new Triangle[numFront]; int n = 0; for (int i = 0; i< numT; i++){ if (visibleT[i]!= invisibleT) { sortedT[n] = new Triangle(visibleT[i], vertices2); n += 1; } } Arrays.sort(sortedT); } }
Image of page 6

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern