- Home /
Clamp a Vector above minimum angle from another Vector?
I've got a weird one.
Seems basic, feels like it's got an elegant solution, but I can't figure it out...
I'm trying to create a function like:
Vector3 FindsNearestPermittedVector
(Vector3 reference, Vector3 maybeReject, float minimumAngleAllowable)
Like say I'm trying to avoid any Vectors pointing within 30 degrees of Vector3.up.
And then say I start generating random vectors... If Vector3.Angle(randomVector, Vector3.up) < 30, then I don't want it! But then I also have to calculate an appropriate angle. That follow up is the hard part.
How to do??
Extra details:
It's like I need some kind of 3D Vector clamp cone. Where all angles are permitted except any that are within X degrees of a vector (so you get a forbidden cone). Well I mean, the forbidden area is easy to do. Just Vector3.Angle. But how do I find the nearest permitted point?
Right now I'm thinking of using a While loop to keep measuring Vector3.Angle ... and I suppose I could create AND rotate a gameobject's forward... until it's angle is > 30 degrees again.
Maybe that's it? Use gameObject manipulation in calculation. Just seems so messy.
Ps. The gist of what I'm doing is to have one "chasing" object (used for other calculations) maintain position directly behind another unless the runner goes straight upward.
Any ideas?
Your answer
Follow this Question
Related Questions
What's with this absurd index array input? 1 Answer
Rotating smoothly between two angles - Mathematical formula? 4 Answers
How to make that the camera will not go through the walls? 1 Answer
Rotate on one axis and check if angle is inside desired range 2 Answers
Trouble coding a peeking system like in Rainbow Six Siege??? 1 Answer