Well I'm not sure about your IDE of choice as I do not use it. If you want to use DOS then the compiler must support interrupts and DOS programs. MSVC does not, but I'm not sure about Dev-C.
As far as rotating and scaling these will do the trick. I will write them in Visual Basic code.
Code:
type point3D
x as single
y as single
z as single
end type
type ipoint2D
x as integer
y as integer
end type
type vertex3D
model as point3D
world as point3D
view as point3D
scrn as point2D
tex as point2D
end type
type object3D
verts() as vertex3D
numverts as long
vertindices() as integer
numindices as integer
position as point3D
mrotation as point3D
wrotation as point3D
end type
'0-based arrays
option base 0
sub SetRotationZ(angle as single,matrix[4][4] as single)
'angle is specified in radians
'radians = (degrees*PI/180)
'Setup Z rotation matrix
matrix[0][0]=cos(angle)
matrix[0][1]=-sin(angle)
matrix[1][0]=sin(angle)
matrix[1][1]=cos(angle)
matrix[0][2]=0:matrix[0][3]=0
matrix[1][2]=0:matrix[2][3]=0
matrix[2][0]=0:matrix[2][1]=0:matrix[2][2]=1:matrix[2][3]=0
matrix[3][0]=0:matrix[3][1]=0:matrix[3][2]=0:matrix[3][3]=1
end sub
sub MatrixMultiply(m1[4][4] as single,m2[4][4] as single,result[4][4] as single)
for i=0 to 3 step 1
for j=0 to3 step 1
result[i][j]=0
for k=0 to 3 step 1
result[i][j]=m3[i][j]+(m1[i][k]*m2[k][j])
next
next
next
end sub
sub ModelToWorld(verts() as vertex3D,numverts as long,matrix[4][4] as single)
dim i as long
for i=0 to numverts
mx=verts(i).model.x
my=verts(i).model.y
mz=verts(i).model.z
wx=mx*matrix[0][0]+my*matrix[1][0]+mz*matrix[2][0]+matrix[3][0]
wy=mx*matrix[0][1]+my*matrix[1][1]+mz*matrix[2][1]+matrix[3][1]
wz=mx*matrix[0][2]+my*matrix[1][2]+mz*matrix[2][2]+matrix[3][2]
'Discard w for now
verts(i).world.x=wx
verts(i).world.y=wy
verts(i).world.z=wz
next
end sub
sub WorldToView(verts() as vertex3D,numverts as long,matrix[4][4] as single)
dim i as long
for i=0 to numverts
wx=verts(i).world.x
wy=verts(i).world.y
wz=verts(i).world.z
vx=wx*matrix[0][0]+wy*matrix[1][0]+wz*matrix[2][0]+matrix[3][0]
vy=wx*matrix[0][1]+wy*matrix[1][1]+wz*matrix[2][1]+matrix[3][1]
vz=wx*matrix[0][2]+wy*matrix[1][2]+wz*matrix[2][2]+matrix[3][2]
'Discard w for now
verts(i).view.x=wx
verts(i).view.y=wy
verts(i).view.z=wz
next
end sub
sub SetTranslation(dx as single,dy as single,dz as single,matrix[4][4] as single)
matrix[3][0]=dx
matrix[3][1]=dy
matrix[3][2]=dz
matrix[3][3]=1
matrix[0][0]=1:matrix[0][1]=0:matrix[0][2]=0:matrix[0][3]=0
matrix[1][0]=0:matrix[1][1]=1:matrix[1][2]=0:matrix[1][3]=0
matrix[2][0]=0:matrix[2][1]=0:matrix[2][2]=1:matrix[1][3]=0
end sub
sub SetScaling(sx as single,sy as single,sz as single,matrix[4][4] as single)
matrix[0][0]=sx
matrix[1][1]=sy
matrix[2][2]=sz
matrix[3][3]=1
matrix[0][1]=0:matrix[0][2]=0:matrix[0][3]=0
matrix[1][0]=0:matrix[1][2]=0:matrix[1][3]=0
matrix[2][0]=0:matrix[2][1]=0:matrix[2][3]=0
matrix[3][0]=0:matrix[3][1]=0:matrix[3][2]=0
end sub
sub MatrixIdentity(matrix[4][4] as single)
matrix[0][0]=1:matrix[1][0]=0:matrix[2][0]=0:matrix[3][0]=0
matrix[0][1]=0:matrix[1][1]=1:matrix[2][1]=0:matrix[3][1]=0
matrix[0][2]=0:matrix[1][2]=0:matrix[2][2]=1:matrix[3][2]=0
matrix[0][3]=0:matrix[1][3]=0:matrix[2][3]=0:matrix[3][3]=1
end sub
sub Project(verts() as vertex3D,numverts as long,disttoplane as single,cx as integer,cy as integer)
for i=0 to numverts
vx=verts(i).view.x
vy=verts(i).view.y
vz=verts(i).view.z
sx=(vx*disttoplane)/vz+cx
sy=(vy*disttoplane)/vz+cy
verts(i).screen.x=sx
verts(i).screen.y=sy
next
end sub
To use this as a 2D system set all you z vertex components to 1.
Here is one way to use this:
1. Create an object of type object3D
2. Create your vertexes for your object or load them from disk
3. Create your indices for this object or load from disk
4. Create a master transformation matrix
5. Call translation function to set position in world space
6. Call scaling function to set scale factors in world space
7. Call rotation function to rotate object in model space
8. Do rotation*scaling*translation and store in matrix
9. Pass model's vertexes and the matrix from step 8 to ModelToWorld
10. Call rotation function to rotate object in world space (like earth orbiting sun)
11. Set master matrix to identity
12. Translate, rotate, scale object in view space by calling correct function
13. Do rotation*scaling*translation and store in matrix
14. Pass model's vertexes and the matrix from step 13 to WorldToView
15. Compute projection plane
16. Do clipping on model vertexes
17. Call Project with model's vertexes, distance to plane of projection, center of screen on x and y
18. Draw clipped object in screen space using scrn coordinates from step 17
19. Draw lines from verts(indices) to verts(indices+1).
Note that this pseudo graphics pipeline leaves out z buffering, texturing, lighting, rasterization, clipping, etc., etc. It is extremely primitive. But you can use it for 2D as long as your screen coords are guaranteed to be within the screen extents.
That's a lot of information and should keep you busy for some time.
Incidentally we cannot explain every graphic concept in one post. You can clearly see why. I would recommend buying some books on the topic from www.amazon.com