Plot - 3D prjection on 2D
this code is created first by chatGPT on Feb 4 2023 (meaning using chatGPT 3.5) and then modified a little bit my me. The initial request that I put into chatGPT is as follows :
NOTE : As you may notice, I put many of the function prototype in the requirement. When you are putting complicated / long requirement, I would suggest you to break them down into several functions and put those functions as a requirement. If you put the complicated requirement, it is highly likely for the chatGPT to hang up while writing the code. If you break down the requirement into several functions, you can easily let chatGPT complete the writing by saying 'rewrite this function'.
NOTE : It is not guaranteed that you would have the same code as I got since chatGPT produce the answers differently depending on the context. And it may produce the different answers everytime you ask even with the exact the same question.
NOTE : I noticed that chatGPT misses some of the requirement or misinterprets.
NOTE : If you don't have any of your own idea for the request, copy my request and paste it into the chatGPT and put additional requests based on the output for the previous request. I would suggest to create a new thread in the chatGPT and put my request and then continue to add your own request.
Usage : Click on [Draw] button or change numbers in the inputbox by click on the spin button, you will get a 3D coordinate and a cube projected onto 2D canvas.
NOTE : red line indicates x axis, green line indicates y axis and blue line indicates z axis.
NOTE : I downloaded the math.js library from Mathjs homepage and placed in local path : mathjs/math.js
NOTE : I took me longer time for me to debug this code than other examples. It seems chatGPT is not well trained with the details of handling the details of canvas.