AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Extend Line and get it's origin (https://forums.alliedmods.net/showthread.php?t=86847)

shine771 03-03-2009 12:11

Extend Line and get it's origin
 
I have 2 origins, i created a beam between them(line). I want to extend the line, and get it's end origin. Example image:
[IMG]http://img91.**************/img91/6706/imgm.jpg[/IMG]
The black dots are origins i have. The red dot is the origin what i need. I want to know the formula or a function how to do this.

Thanks.

Exolent[jNr] 03-03-2009 12:21

Re: Extend Line and get it's origin
 
Code:
// this goes from origin1 to origin2 and extended to origin3 new Float:origin1[3]; // fill your 1st origin new Float:origin2[3]; // fill your 2nd origin new Float:vector[3]; xs_vec_sub(origin2, origin1, vector); new Float:length = xs_vec_len(vector); xs_vec_normalize(vector); new Float:extended; // set extended to your extra distance to find origin 3 xs_vec_mul_scalar(vector, length + extended, vector); new Float:origin3[3]; xs_vec_add(origin1, vector, origin3); // origin3 holds the extended line end point

shine771 03-03-2009 13:03

Re: Extend Line and get it's origin
 
Big thanks!


All times are GMT -4. The time now is 16:53.

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