Pages: 12

@Lumpkin

Ok, but if you are going to have a go at 3d modelling, then you ought to learn some of this stuff.

So you need to get rid of your existing operator* - it doesn't make sense.

The scalar product is really easy to implement, so is the dot product.

I might as well explain here, the wiki pages are a bit of a nightmare.

First the length or magnitude of a vector |a| = sqrt( (a.x)^2 + (a.y)^2 + (a.z)^2 )

To work out the distance between 2 points p & q, first do (q -p) then use the formula above.

scalar product - multiply a vector (vector a) by a real number (the scalar s). This increases the length of a by a factor of s.

s * a = (s* a.x, s * a.y, s* a.z)

The Dot Product multiplies 2 vectors to give a real number as the answer, and this value equals the cosine of the angle (theta) between them multiplied by the length of each vector.

a dot b = (a.x * b.x + a.y * b.y + a.z * b.z) = |a| * |b| * cos theta

A Unit Vector (aka normalised vector) is a vector with a length of 1.0. It is he vector multiplied by 1 over the length of the vector.

unit vector of a = (1 / |a|) * a = ( (1/|a| * a.x), (1/|a| * a.y) , (1/|a| * a.z) )

Now that I have done that, I found this:

It is pretty clear, but it uses the notation a1, a2, a3 instead of ax, ay, az. This is because a co-ordinate system might not be parallel to the x, y ,z axes.

The cross product works out a normal vector to a plane defined by 2 vectors. Normal vectors are often expressed as Unit vectors.

Hope this info is useful for for you & can add it into your code - should be easy.

EDIT: IMO you should have an operator- , you don't want to have to fool around multiplying by a scalar of -1 when you could just subtract.

Ok, but if you are going to have a go at 3d modelling, then you ought to learn some of this stuff.

So you need to get rid of your existing operator* - it doesn't make sense.

The scalar product is really easy to implement, so is the dot product.

I might as well explain here, the wiki pages are a bit of a nightmare.

First the length or magnitude of a vector |a| = sqrt( (a.x)^2 + (a.y)^2 + (a.z)^2 )

To work out the distance between 2 points p & q, first do (q -p) then use the formula above.

scalar product - multiply a vector (vector a) by a real number (the scalar s). This increases the length of a by a factor of s.

s * a = (s* a.x, s * a.y, s* a.z)

The Dot Product multiplies 2 vectors to give a real number as the answer, and this value equals the cosine of the angle (theta) between them multiplied by the length of each vector.

a dot b = (a.x * b.x + a.y * b.y + a.z * b.z) = |a| * |b| * cos theta

A Unit Vector (aka normalised vector) is a vector with a length of 1.0. It is he vector multiplied by 1 over the length of the vector.

unit vector of a = (1 / |a|) * a = ( (1/|a| * a.x), (1/|a| * a.y) , (1/|a| * a.z) )

Now that I have done that, I found this:

http://www.math.dartmouth.edu/archive/m9f07/public_html/m9lect1031.pdf |

It is pretty clear, but it uses the notation a1, a2, a3 instead of ax, ay, az. This is because a co-ordinate system might not be parallel to the x, y ,z axes.

The cross product works out a normal vector to a plane defined by 2 vectors. Normal vectors are often expressed as Unit vectors.

Hope this info is useful for for you & can add it into your code - should be easy.

EDIT: IMO you should have an operator- , you don't want to have to fool around multiplying by a scalar of -1 when you could just subtract.

Last edited on

Eh, once school starts in 3 weeks I'll ask my math teacher 'bout it.

I have a model and stuff ready, a concrete barrier. All I have to do is figure out how to save floats and ints in binary with python for my loader.

The model is simple. I convert it to triangles before export though.

http://prntscr.com/1l2g31

I have a model and stuff ready, a concrete barrier. All I have to do is figure out how to save floats and ints in binary with python for my loader.

The model is simple. I convert it to triangles before export though.

http://prntscr.com/1l2g31

Topic archived. No new replies allowed.

Pages: 12