Question: CENG 2001- C Programming - Fall 2020 Homework #7 Due date: 12/01/2021 - 13:00 Assignment: Write a program that reads an obj file (a file

 CENG 2001- C Programming - Fall 2020 Homework #7 Due date:

CENG 2001- C Programming - Fall 2020 Homework #7 Due date: 12/01/2021 - 13:00 Assignment: Write a program that reads an obj file (a file to represent a 3D model), computes the center of mass of the model and translates the model in given x,y,z direction. Center of mass of an 3D model is computed as (mean(x), mean(y), mean(z)) Meaning mean value of all x values in 3d points, mean value of all y values and z values respectively. * Write a function that will get the array of the Point3D and the number of points as input and will return a Point3D struct to compute the center of mass * Display the resultant Point3D using printf(x, y, and z values of the center of mass) * Write a function that will translate each point by the given x,y,z values. These values will be obtained from the user. * Store the translated points in a file with the same format as the obj file (So that you can visualize the result.) * To store the resu * For vertices v followed by x, y, and z coordinates for each vertices * For faces, just copy the same values from the input obj file. Translation is performed by adding the corresponding x,y,z values to each 3d points of the model. Obj files store 3d points as well as faces (triangles formed by 3 3d points). Points, also named as vertices, start with the letter 'v' while faces start with Notes: 'f'. In this assignment, you will only need the lines with 'v'. You can use fscanf(fp,"%c %f %f % ", &f_or_v, &x, &y, &z) to get values at each line. (f_or_v is char, x, y, and z are float variables.) It is unknown how many points exist in the file. Use feof function. A sample obj file will be provided with the homework. You can view the model by using https://3dviewer.net Steps to perform: Form a struct named Point3D that has 3 floating variables namely x,y,z (check lecture notes) * Get the number of 3d points. (Open the file, get the number of lines that start with 'v') * Dynamically allocate an array of size equal to the number of 3d points and type Point3D. Submit: All.cpp and .header files

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!