AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved get position between N points (https://forums.alliedmods.net/showthread.php?t=337427)

kww 04-20-2022 04:41

get position between N points
 
Hello everyone1 Is there any formula or snippet that could count the origin between N points?
Example: I have a[3], b[3], ..., N[3], and I need to count the center between them.
Thanks in advance

zXCaptainXz 04-20-2022 06:36

Re: get position between N points
 
I’m sorry but your question is not so clear, when you say "count", it means that the output should be one of the points? What do you mean exactly by "origin" and "center"? An example with actual numbers would be appreciated.

OciXCrom 04-20-2022 14:15

Re: get position between N points
 
Do you mean calculate the distance between them?

CrazY. 04-20-2022 21:22

Re: get position between N points
 
The midpoint can be found by summing each axis and dividing by the number of points.
Assuming your points are A, B, and C:

Code:
// 0 - x axis // 1 - y axis // 2 - z axis center[0] = (A[0] + B[0] + C[0]) / 3 center[1] = (A[1] + B[1] + C[1]) / 3 center[2] = (A[2] + B[2] + C[2]) / 3

kww 04-21-2022 05:41

Re: get position between N points
 
Quote:

Originally Posted by CrazY. (Post 2777401)
The midpoint can be found by summing each axis and dividing by the number of points.
Assuming your points are A, B, and C:

Code:
// 0 - x axis // 1 - y axis // 2 - z axis center[0] = (A[0] + B[0] + C[0]) / 3 center[1] = (A[1] + B[1] + C[1]) / 3 center[2] = (A[2] + B[2] + C[2]) / 3

Thank you. This definitely gonna help me!


All times are GMT -4. The time now is 04:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.