Maths question spawning ent around circle

Posted By: robertbruce

Maths question spawning ent around circle - 04/12/12 15:43

Hello,

How could I code an object that spawns entities around it in a circle at a set distance.

For instance, a random angle is chosen 1-360 and the object is spawned at distance of 100 at the random angle.

I can think of several ways of doing this like random pan then move to set distance but there must be a mathematician who knows better.

thanks,
Rob
Posted By: txesmi

Re: Maths question spawning ent around circle - 04/12/12 16:07

Hi!

Code:
SpawnPos.x = Center.x + fsin ( Angle, Distance );
SpawnPos.y = Center.y + fcos ( Angle, Distance );



The conditions of the operations depend on the coordinate system, as well as the addition or subtraction of the same.

Wellcome to trigonometry!
Posted By: JoGa

Re: Maths question spawning ent around circle - 04/12/12 16:08

I'm at cooking, so I can't write a roman, but here a idea:

I made something like this some weeks ago (spawming PowerUps in a cycle)
Code:
int anzahl = 5; //numbers of Ents
	VECTOR vec_platzierung;
	var drehung = 360 / anzahl;
	vec_set(vec_platzierung, vector(300,0,0)); // place around 0,0,0 with distance of 300 Quants
	for(i=0;i<anzahl;i++)
	{
		vec_rotate(vec_platzierung, vector(drehung,0,0)); // turn the place around
		you = ent_create(...);
	}



edit: txesmi was quicker and did it like a (math) boss ^^
Posted By: robertbruce

Re: Maths question spawning ent around circle - 04/12/12 21:59

thanks for the maths lessons. Will give them a try.

best regards,
Rob
© 2024 lite-C Forums