Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions