[Maths] Given 2 points, retrieve a point between them
Hey there, I'm having trouble with a maths problem that I don't know how to put into code, hopefully this diagram helps explain what I'm looking for.
https://i.imgur.com/5q3byW7.png I have 2 points, Point A and Point B, I want to travel along the line between them for a set amount of distance and then retrieve Point C. I can get the angle of this line no problem, I just don't know how to travel a set distance along it. It'd be like a TraceRay except you use a vector and travel along it a fixed distance and retrieve the end point. Thanks for your time. |
Re: [Maths] Given 2 points, retrieve a point between them
Quote:
Teleports you to a target position on where I aim, and if you're stuck, teleports you backwards across the angle of my aim until you're not stuck https://github.com/eyal282/Useful-Co...fulCommands.sp sm_blink |
Re: [Maths] Given 2 points, retrieve a point between them
Hey there, thanks for the pointer, I've made a solution from it that works reasonably well, it only slightly falls short because the distance is a scalevector created from angles, so the distance is fairly inconsistent, but it generally works. Thanks.
Edit: Actually, with normalizing the vector and scaling it by a greater amount it gives a much more consistent result, cheers! |
Re: [Maths] Given 2 points, retrieve a point between them
If you have the two points A and B and need a distance L along the line from the start, you'd want to create a vector from B - A, then normalize and scale by L.
If you have one point A and an angle, get the forward unit vector from the angle (in SourceMod you'd use GetAngleVectors), then scale that by L. |
Re: [Maths] Given 2 points, retrieve a point between them
Quote:
|
| All times are GMT -4. The time now is 21:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.