Computer Science For Digital Engineering Assignment Report
Computer Science For Digital Engineering Assignment Report
Year: 2024
2
CONTENTS
1. Introduction
4. Conclusion
5. References
3
I honestly declare that this dissertation is entirely my own work and none of its part has been copied
from printed or electronic sources, translated from foreign sources and reproduced from essays of
other researchers or students. Wherever I have been based on ideas or other people texts I clearly
declare it through the good use of references following academic ethics.
(In the case that is proved that part of the essay does not constitute an original work, but a copy of
an already published essay or from another source, the student will be expelled permanently from
the postgraduate program).
Date: ...........14........../..03......../...2025......
4
1. Introduction
Computer science plays a vital role in modern digital engineering. This report presents two
different tasks that showcase the application of computer science concepts in practical
scenarios. The first task involves creating a C++ program to calculate the cosine similarity
between two text inputs. Text similarity measures help us understand how close two
documents are in meaning (Manning et al., 2008). The second task demonstrates the use of
CAD software to design a 3D pencil model. Computer-aided design helps engineers create
precise digital models before manufacturing (Narayan, 2008). Both tasks highlight different
aspects of computer science in digital engineering fields. This report will explain the
Cosine similarity measures the similarity between two non-zero vectors. It calculates the
cosine of the angle between them. Two identical texts will have a cosine similarity of 1.
Completely different texts will have a value of 0 (Singhal, 2001). The formula uses the dot
product of two vectors divided by their magnitudes. Cosine similarity works well for text
analysis because it focuses on content rather than size. This makes it useful for comparing
documents of different lengths. The mathematical formula looks like this: cos(θ) = (A·B)/(|A|
×|B|) where A and B represent our text vectors (Huang, 2008). Many search engines and
recommendation systems use this method today. It helps find related documents based on
Text documents need to be converted into vectors first. Each unique word becomes a
dimension in the vector space. The frequency of each word becomes the value in that
5
dimension. This approach is called the "bag of words" model. It ignores word order but
preserves frequency information (Rajaraman and Ullman, 2011). Higher cosine similarity
values mean the texts contain similar words. Lower values suggest different vocabulary and
likely different topics. The calculation gives results between 0 and 1 for normal text analysis.
The cosine similarity algorithm follows several clear steps. First, we tokenize both input texts
into individual words. Tokenization breaks down sentences into separate words for analysis
(Bird et al., 2009). Next, we count the frequency of each word in both texts. These
frequencies form our vector representations of the texts. We then identify all unique words
across both documents. This gives us the dimensions of our vector space model. The dot
product calculation multiplies matching word frequencies together. We sum these products to
For the magnitude calculations, we square each word frequency. We sum these squares for
each document separately. Then we take the square root of these sums. This gives us the
magnitude (length) of each document vector. Finally, we divide the dot product by the
product of both magnitudes (Turney and Pantel, 2010). This normalization step ensures our
result falls between 0 and 1. The entire process focuses on word overlap between documents.
It works well for detecting semantic similarity in short texts. Our implementation follows this
The C++ program uses several standard libraries for implementation. The iostream library
handles input and output operations. The map container stores word frequencies as key-value
pairs. Stringstream helps with text parsing and word extraction. The cmath library provides
6
mathematical functions like square root (Stroustrup, 2013). The set container stores unique
words from both texts. The iomanip library helps format the output display nicely. These
standard libraries make the code more efficient and readable. They provide built-in
The program includes three main functions for clear organization. The getWordFrequency
function counts words in each text input. The computeCosineSimilarity function performs the
mathematical calculations described earlier. The displayResult function shows the final
similarity score visually. This modular approach makes the code easier to understand
(McConnell, 2004). The main function coordinates the overall program flow. It collects user
input and calls the other functions in sequence. The program handles edge cases like empty
inputs appropriately. It also formats the output inside a rectangle for better presentation.
The program successfully calculates cosine similarity between text inputs. In the first test
case, we compared "Machine learning is powerful" with "Machine learning is amazing". The
result showed a cosine similarity of 0.7500. This high score makes sense because the texts
share many words. Only one word differs between them, which explains the similarity
8
(Mihalcea et al., 2006). The second test compared longer and more different texts. It returned
a lower similarity score of 0.4146. This correctly reflects the reduced word overlap between
inputs. The program handles these different cases accurately and consistently.
The rectangular display format makes the results easy to read. Users can quickly see the
similarity score in a highlighted box. The precision is set to four decimal places for accuracy.
This provides enough detail without overwhelming the user (Nielsen, 2000). The program
processes inputs efficiently even with longer texts. It handles special characters and maintains
retrieval principles. It successfully captures semantic similarity between different text inputs.
Testing with various examples confirmed the program's reliability and accuracy.
The 3D object design task focused on creating a pencil. Pencils are familiar objects with
interesting design features. They combine geometric shapes in a functional form. The pencil
design includes a hexagonal body and conical tip. These features make it a good subject for
CAD modeling. The design would include "OM Pencils" text and "HB" marking. These
elements add realism and personalization to the model (Bethune, 2017). The pencil represents
an everyday object with precise specifications. It demonstrates both artistic and technical
design aspects.
The initial concept started with standard pencil dimensions. Regular pencils measure about
19cm in length and 7mm in width. These measurements provided a starting point for the
design. The hexagonal body helps prevent rolling on flat surfaces. The sharp conical tip
represents the writing point (Pipes, 2007). The eraser component was omitted for simplicity.
This focused the design on the main pencil body. The text placement needed careful
9
consideration for visibility. The "HB" marking indicates pencil hardness in real-world
The 2D design began in AutoCAD with basic shape creation. The pencil's hexagonal profile
forms the basis of the design. The hexagon was drawn using the polygon tool with six sides.
Proper dimensions ensured the design matched standard pencil proportions (Yarwood, 2016).
The pencil tip was drawn as a triangle at one end. This would later be revolved to create the
conical shape. The dimensions were carefully labeled for manufacturing clarity. This detailed
The 2D drawing included guidelines for text placement. The "OM Pencils" text would appear
along the body length. The "HB" marking would appear near one end of the pencil. These
text elements were positioned for maximum visibility (Bethune, 2017). The drawing used
proper CAD conventions for clarity. Lines were drawn on appropriate layers with consistent
10
styles. The completed 2D design contained all necessary information for 3D modeling. This
Converting the 2D design to 3D required several modeling techniques. The hexagonal profile
was extruded to create the pencil body. Extrusion converts 2D shapes into 3D objects with
depth (Tickoo, 2014). The triangular tip was revolved around its axis. This created the conical
pencil point with proper dimensions. The sharp tip was crucial for realistic appearance. The
transition between body and tip needed careful attention. The model maintained proper
The 3D model required precise angle measurements for the tip. Standard pencils have
approximately 30-degree tip angles. The digital model followed this specification for
accuracy (Yarwood, 2016). The hexagonal body maintained consistent dimensions along its
length. The edges were slightly beveled for realism. These small details improved the visual
11
quality of the model. The CAD software's measurement tools ensured dimensional accuracy.
Adding text to the 3D model required specific CAD tools. The text tool created the "OM
Pencils" label along the body. The text followed the pencil's contour for natural appearance.
The "HB" marking was added near the hexagonal end. Both text elements used appropriate
font styles and sizes (Cohn, 2018). The text depth was set for clear visibility. This ensured the
text would appear properly in all viewing angles. The text positioning followed standard
pencil labeling conventions. This attention to detail enhanced the model's professional
appearance.
Color customization made the model more visually appealing. The pencil body received a
gray color resembling graphite. The tip area featured a subtle orange color for the wood.
These color choices reflected real-world pencil materials (Bethune, 2017). The text elements
were colored white for contrast. This made them easily readable against the darker body. The
color application used the CAD software's material tools. These tools allowed precise control
over color placement. The finished model combined accurate geometry with appropriate
The completed 3D pencil model successfully met all requirements. It featured accurate
dimensions matching real-world specifications. The hexagonal body and conical tip showed
proper proportions. The text elements appeared clearly on the model surface. The color
scheme enhanced visual realism effectively (Cohn, 2018). The model demonstrated good
The CAD implementation showed proper use of modeling techniques. The design achieved
The final review revealed some potential improvements for future models. The eraser end
could be added for completeness. More texture details could enhance surface realism.
Advanced material properties could improve visual rendering (Tickoo, 2014). However, the
use of CAD design principles. The model showcases both technical accuracy and aesthetic
4. Conclusion
processed text inputs and displayed meaningful similarity scores. The program handled
various test cases accurately and efficiently. The cosine similarity algorithm proved effective
13
for text comparison tasks. The visual display enhanced user understanding of the results. This
shows how mathematical concepts translate into useful software tools (Baeza-Yates and
Ribeiro-Neto, 2011).
The CAD design portion showcased 3D modeling capabilities. The pencil model progressed
from 2D concept to detailed 3D object. It incorporated text elements and color customization
successfully. The model maintained accurate proportions and realistic features. The design
process followed professional CAD practices throughout. This demonstrated the value of
computer-aided design in engineering. It showed how digital tools help create precise
showed how theoretical concepts apply to practical challenges. The skills developed here
transfer to many engineering disciplines. They help bridge the gap between computer science
and physical engineering. Future work could explore more advanced implementations of both
tasks. The programming component could incorporate more sophisticated text processing.
The CAD design could explore more complex geometric forms. These projects demonstrate
the growing integration of computer science. They show its essential role in modern digital
engineering practices.
14
5. References
and Technology Behind Search. 2nd edn. Harlow: Addison-Wesley. Available at:
https://doi.org/10.1145/2009916.2010148
Bethune, J.D. (2017) Engineering Graphics with AutoCAD 2018. New York: Industrial Press.
Bird, S., Klein, E. and Loper, E. (2009) Natural Language Processing with Python.
language-processing/9780596803346/
Cohn, D. (2018) AutoCAD 2019 and AutoCAD LT 2019 Essentials. Indianapolis: Wiley.
Available at:
https://www.wiley.com/en-us/AutoCAD+2019+and+AutoCAD+LT+2019+Essentials-p-
9781119495475
Garcia, E. (2016) 'Cosine similarity tutorial', Information Retrieval Blog, 14 March. Available
at: http://www.minerazzi.com/tutorials/cosine-similarity-tutorial.pdf
Huang, A. (2008) 'Similarity measures for text document clustering', Proceedings of the New
Zealand Computer Science Research Student Conference, pp. 49-56. Available at:
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.332.4480&rep=rep1&type=pdf
https://doi.org/10.1017/CBO9780511809071
15
https://www.microsoftpressstore.com/store/code-complete-9780735619678
https://www.aaai.org/Papers/AAAI/2006/AAAI06-123.pdf
Narayan, K.L. (2008) Computer Aided Design and Manufacturing. New Delhi: Prentice Hall
Nielsen, J. (2000) Designing Web Usability: The Practice of Simplicity. Indianapolis: New
Pipes, A. (2007) Drawing for Designers. London: Laurence King Publishing. Available at:
https://www.laurenceking.com/products/drawing-for-designers
Rajaraman, A. and Ullman, J.D. (2011) Mining of Massive Datasets. Cambridge: Cambridge
Singhal, A. (2001) 'Modern information retrieval: A brief overview', IEEE Data Engineering
Stroustrup, B. (2013) The C++ Programming Language. 4th edn. Boston: Addison-Wesley.