How do I work out vertex coordinates after rotation
Blitz3D Forums/Blitz3D Programming/How do I work out vertex coordinates after rotation
| ||
| Ok, I have manually created a face with 4 vertices. If x,y=0 then the vertices would be created at (-1,-1 : -1,1 : 1,1 : 1,-1) This therefore means that the angle of point x,y is 0 Say i wanted to rotate 30 degrees the center point x,y, how would I manually calculate the position of the 4 vertices. Obviously it is a SIN/COS thang, but any examples? (This is for a single surface particle system i am doing) Cheers Rob |
| ||
Sorry, just worked it out, here is the code if you're interested
graphics3d 320,240,16,3
x=160
y=120
dist=1
angle#=0
while not keyhit(1)
cls
plotdot(x,y,angle,-10,-10)
plotdot(x,y,angle,-10,10)
plotdot(x,y,angle,10,10)
plotdot(x,y,angle,10,-10)
if kEyhit(57)
angle = angle + 9
end if
flip
wend
end
function plotdot(x,y,angle#,xadd=1,Yadd=1)
new_x# = x + (xadd * cos(angle) - yadd * sin(angle))
new_y# = y + (yadd * cos(angle) + xadd * sin(angle))
color 255,255,255
plot new_x,new_y
end function
|
| ||
| Don't forget a lookup table for speed :) |
| ||
| Thanks Rob, that was my next step :) |