Tag Info

New answers tagged

0

You could also achieve this in a "dumb" cycle, it is not optimal but will work. Simply keep adding any block next to the current that is inside the area. Lets say you would like a list of the blocks: Rectangle area = new Rectangle(A.x, Math.Max(B.y,B.x), A.y, Math.Min(B.y,B.x)); List<Block> blocks = new List<Block>(); Queue<Block> ...


-1

Is this in 2d? For 2d: The position of the block you place is {Sin(theta),Cos(theta)} = {x,y}. So at 90degrees, your position will only move in the x-axis by one block each time. The rotation of each block should be the same theta as well.


2

to complete the answer: angle = atan2((C-A).y, (C-A).x) + PI/2;


7

Calculate a vector from B to A, normalize it (divide by the vector's length), then multiply by the circle size: vx = A.x - B.x vy = A.y - B.y length = sqrt(vx*vx + vy*vy) C.x = vx / length * size + A.x C.y = vy / length * size + A.y For the angle you can use the atan2 function, if your language has it.



Top 50 recent answers are included