Forum

> > CS2D > Scripts > Mathematic
Forums overviewCS2D overview Scripts overviewLog in to reply

English Mathematic

25 replies
Page
To the start Previous 1 2 Next To the start

old Re: Mathematic

SQ
Moderator Off Offline

Quote
CS2D Lua and Official one is plain, simple and THE SAME.
And you were using cos function wrong.
You don't even know what COS, SIN, TG, CTG, ARCCOS, ARCSIN and all the freakin trigonometry works.

Just give a basic questions and we'll show how stuff works.

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
Okay

Hello guys,

how can i use math.cos and math.sin ??
i need 1 examples thanks

old Re: Mathematic

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
function fwdcalc(rot,x,y,factor)
	if rot<-90 then rot=rot+360 end
	local angle=math.rad(math.abs(rot+90))-math.pi
	local cx=x+(math.cos(angle)*factor)
	local cy=y+(math.sin(angle)*factor)
	return cx,cy
end

P.S. also, @user SQ:
1
2
DEG_TO_RAD = 0.0174532925199432957692369076848861
math.cos(ANGLE*DEG_TO_RAD)

Can easily be replaced with
1
math.cos(math.rad(ANGLE))
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview