Posted 14 December 2015 - 06:34 PM
                Hi guys,
I have been working on a 3D engine for a week now, and I am having some questions.
When I rotate the object (using a left handed coordinate system), the points move in a weird manner. Instead of staying on the circle, they come inwards:

There are two "parallel" circles because there are tow points. The main concern is that the points come inwards.
This is the code I use for the matrix:
This is the code I use for multiplying the matrix with the position vector (x,y,z,w):
I have striped the useless operations away to make it faster, much faster.
The questions:
Thanks in advance,
Creator.
PS: Before anyone jumps on me saying: "This is not CC!"
I know, I am developing it for Love2D and then porting to CC 2.0
                
            I have been working on a 3D engine for a week now, and I am having some questions.
When I rotate the object (using a left handed coordinate system), the points move in a weird manner. Instead of staying on the circle, they come inwards:

There are two "parallel" circles because there are tow points. The main concern is that the points come inwards.
This is the code I use for the matrix:
rotateZ = function(dergees)
  local radians = rad(dergees)
  local c = math.cos(radians)
  local s = math.sin(radians)
  --[[return {
    c, s, 0, 0,
   -s, c, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1,
  }]]--
  return {
   ["1_1"] = c,
   ["1_2"] = s,
   ["2_1"] = -s,
   ["2_2"] = c,
  }
end,
This is the code I use for multiplying the matrix with the position vector (x,y,z,w):
rotateZ = function(matrix)
   x = x*matrix["1_1"] + matrix["1_2"]*y
   y = x*matrix["2_1"] + matrix["2_2"]*y
  end,
I have striped the useless operations away to make it faster, much faster.
The questions:
- Why does the circle go inwards?
- Is this the correct transformation matrix for rotating around the Z axis on a left hand coordinate system?
- What exactly does w (in the position vector) represent and why is it useful?
- What is the translation matrix?
Thanks in advance,
Creator.
PS: Before anyone jumps on me saying: "This is not CC!"
I know, I am developing it for Love2D and then porting to CC 2.0
 
         
                