Radius offset

I’m having a rather annoying problem here. I have a GizmoPoint(Pink Circle) that follows the rotation and transform of the white line.
The red circle’s radius is an offset position.(yellowLine.x - WhiteLine.x).
This works correctly when the white line has no rotation. However,I can’t figure out how to increase the radius based on the yellow line’s position x.

This is where the gizmo point starts. Moving the yellow line correctly moves the GizmoPoint along with it. (See video 1)


This is what happens after I rotate the white line. (See video 2)


offset.x = (yellowLine.transform.position.x - WhiteLine.transform.position.x); //Set offset based on a dummy object's position
Vector2 GizmoPoint = WhiteLine.transform.position + WhiteLine.transform.localRotation * offset; //Setup gizmo point
Gizmos.DrawWireSphere(GizmoPoint, 1); //Draws the gizmo point

[Small Demonstration]

  1. http://a.pomf.cat/wpygbl.webm (angle=0)
  2. http://a.pomf.cat/jjshxq.webm (angle=-75)

well if you want it up there the yellow line X should ALWAYS be the white line X they should be identical.

as to the Y

well were going to use that ol math standby

Y = mX + B

where M = slope. The slope by the way is just whiteline.transform.forward ASSUMING the white line is pointing towards the yellow one and not the reverse. That white line presumably is pointing that way but basically either transform.up, -transform.up, transform.forward, -trans.for, trans.right, -trans.right

should be the slope of that line. the direction.

so you have slope

y = slope * X + B

we need X & Y, well those are the position of the whiteline.

but we are actuallying lookign for the Y intercept B


whiteline.transform.y = slope * whiteline.transform.X + B;


YIntercept = whiteline.transform.y - (slope * whiteline.transform.x);

now you have the offset Y point and X.

X is the yellowline.x as it always is.

Y is the Yintercept we just solved for.

knowing hwere to place the offset yoru good. I think with then setting circle diameter via vector2.distance (offset, whiteline.position)

Thanks for the answer.
I realized I must have worded my question oddly.

I found the best way to do this was to simply find the intersection point between the two lines.

    Vector2 LineIntersectionPoint(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4)
        // Get A,B,C of first line - points : ps1 to pe1
        float A1 = p2.y - p1.y;
        float B1 = p1.x - p2.x;
        float C1 = A1 * p1.x + B1 * p1.y;

        // Get A,B,C of second line - points : ps2 to pe2
        float A2 = p4.y - p3.y;
        float B2 = p3.x - p4.x;
        float C2 = A2 * p3.x + B2 * p3.y;

        // Get delta and check if the lines are parallel
        float delta = A1 * B2 - A2 * B1;

        if (delta == 0) return Vector2.zero;//Parallel
        // now return the Vector2 intersection point
        return new Vector2((B2 * C1 - B1 * C2) / delta, (A1 * C2 - A2 * C1) / delta);