Noob learns to code in 3 months

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Chrajdal
Posts: 22
Joined: December 15th, 2012, 2:18 pm

Re: Noob learns to code in 3 months

Post by Chrajdal » September 22nd, 2017, 11:06 am

I didn't remember to look in the chillipedia. Nevertheless, I found it there: http://wiki.planetchili.net/index.php?t ... l_6#Errata

I just thought you might be interested in :)

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 22nd, 2017, 11:28 am

Yeah for sure. Never considered it since "why would anyone do that?"

Added this

if (pPixels != rhs.pPixels)

User avatar
Chrajdal
Posts: 22
Joined: December 15th, 2012, 2:18 pm

Re: Noob learns to code in 3 months

Post by Chrajdal » September 22nd, 2017, 11:46 am

Yumtard wrote:Yeah for sure. Never considered it since "why would anyone do that?"

Added this

if (pPixels != rhs.pPixels)
I wouldn't suggest doing that. Suppose, you have several different dynamic arrays in your class. In your assignment operator you would have to check all the pointers eg.:

Code: Select all

if( arr1 != rhs.arr1 && arr2 != rhs.arr2 && arr3 != rhs.arr3 ... )
you get the idea

Simple

Code: Select all

 if(this != &rhs) 
should suffice, I think :)

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » September 22nd, 2017, 12:52 pm

Yeah, either would work, but better to check pointer to whole object than pointer to content I think. More idiomatic.
Chili

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 22nd, 2017, 12:58 pm

solid point

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 28th, 2017, 4:23 pm

Got a good grade on the pokemon simulator. Teacher had a bunch of feedback on things I could've done better tho.

For math assignment we got a framework with a bunch of declared functions we had to implement.

In the vector class we had
Distance()
Add()
Subtract()
DotProduct()
CrossProduct()

Matrix class:
Multiply()
RotateAroundX()
RotateAroundY()
RotateAroundZ()
RotateArouncXYZ()

and finally in the plane class:
bool IntersectsWithLine()

I finished these with a bunch of time to spare so I've added
in vector:
length()
lengthsq()
Normalize()

in Plane:
IntersectionPoint()

in Matrix
Identity()
bool Orthogonal()
bool Orthonormal()
bool Involutory()
Inverse()
Transpose()
Determinant()
Scale()

Overloaded a bunch of operators too to make life easier and make it possible to multiply a matrix with a vector.

Might be forgetting some functions. Not sure what else to add. Wanna be able to do translation but for that I need a 4x4 matrix. The matrix class we got to work with is a 3x3 matrix which has 3 vectors representing its rows.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob learns to code in 3 months

Post by albinopapa » September 28th, 2017, 7:25 pm

Only need a 4x4 if you are doing 3D transformations, which I guess you are. A 3x2 matrix is all that is needed for 2D transformations, so you could still use it especially with your orthogonal view matrix.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 29th, 2017, 7:47 pm

Yeah we're doing 3D

I guess I could add a vector maybe..
Anyways I'm working on something else now. Trying to make a function that returns the line where 2 planes intersect. I know how to do it mathematically but having some trouble translating it into code.

Atm I'm always setting x to 0. This makes the function work, but not for all cases.. Will try to figure something out.

Found this on stackoverflow.


Image

he adds these 2 equations and get this result:

Image

could someone help me understand how he manages to get z by itself on the left hand side?
When I try adding these I get stuck with the left side being
(-B2/B1)*C1z + C2z
And I can't figure out a way to get this thing down to just z

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 29th, 2017, 8:49 pm

nvm his answer was incorrect

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » September 29th, 2017, 10:49 pm

Image

yay. Think I should be able to fix my function now

Post Reply