Monday, April 28, 2025
HomeGame Developmentarithmetic - Given two factors (A and B), how can I acquire...

arithmetic – Given two factors (A and B), how can I acquire a degree a set distance alongside the road between them?


For instance I’ve place A, that’s (0,0) and Place B that’s (10,5).

Now for instance I do know that place C is 5 items’ distance from place A in path to Place B.

Offered that the equation for distance is (BX-AX)+(BY-AY)/2.

Clarification of the gap equation: You normalize the indicators so each values are constructive or adverse after which take the one with greater values, on this case BX, and take away the one with decrease values from it, on this case AX, that is for every parenthesis, in different phrases (AY-BY) as a second place may very well be an choice if AY was greater than BY, which isn’t the case right here, so the context of the X would not matter for the ordering of Y, or Z if it was a dimension that have been current right here. After that, having all of the variations between the totally different dimensions from the factors, you sum all of them as much as acquire a single quantity after which divide that quantity by the whole variety of dimensions.

I am not utilizing coords in a globe however making readings in straight traces being 2D or 3D, so this works for me.

Again to the query:

How can I acquire place C?

The problem right here is ensuring that I get the purpose at that distance that’s between place A and place B. As a result of if I resolve the equation of distance I can acquire a number of positions round Place A that match the gap standards, so how can I make sure than I select the one exactly between A and B?

Please reply in non-unity C# if potential, pseudocode can also be welcomed, however keep away from utilizing heavy math indicators troublesome to program round if potential.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments