Find point between object and mouse position

How do I rotate the 1st object around a 2nd object based off of the mouse position relative to the Second object.

Hard to describe so please check out the picture.

[27839-raycast+example.png|27839]

So, I need to rotate the object (ORANGE) around a Ball (RED) dependent on the position of the Mouse (BLUE) in 3d space.

I was thinking the best way to do this would be to get a raycast from the mouse position to a plane. Then get a second raycast (GREEN) from the ball to the mouse position. And then position the Object (ORANGE) a certain distance down the raycast.

I guess, I’m wondering if this is the easiest way to do this or am I missing something even easier.

If this is the easiest then I’ll move forth and try to do this.

If you don’t understand what I’m talking about still, think MiniGolf. Any assistance in this matter is greatly appreciated. Thanks.

You don’t need a raycast. Your green line is the vector resultant of blue minus red. I think that this could (not tested) explain better.

``````// compute green vector
var delta = blue.transform.position - red.transform.position;
// get its dir
var dir = delta.normalized;
// get its length
var mag = delta.magnitude;

// place the orange in the green vector direction in distance 10% of its length relative to blue position
orange.transform.position = dir * mag * 0.1f + blue.transform.position;
``````