What is the correct way to move objects relative to each other ?

When a parent object has a child object it is very easy to rotate and move the parent and have to child remain in the correct position relative to the parent.
In order to move the child from one parent to another while maintaining the relative position it seems really easy to copy transform.local.position and transform.local.rotation from one parent to another.

Unfortunately for my application the object I’m trying to move is not a child of the first object and will not become the child of the second.
I still need to maintain the relative positioning when the test rig is moved from its relative position from the starting plane to its new position relative to the ending plane in three dimensions.

Here is a two-dimensional representation of what is needed:


It seems to me that this type of relative movement is the basic component of unity.
Unfortunately I can’t seem to decipher the correct functions to use.

The following code works:

but I feel there must be a much better and simpler and more efficient way to accomplish the task.

Any pointers would be greatly appreciated.

PS: my previous account fails whenever I login so I was forced to create a new account for this post. My apologies for duplicating the question.

using UnityEngine;
using System.Collections;

public class TestTriggerRight : MonoBehaviour {

    public string MyName; // use this name to tell thing apart
    public GameObject StartingPlane; //Plane Object with Rig Object position somewhere around it 
    public GameObject EndingPlane; // Plane Objece that we want to move the rig Object to
    public GameObject TestRig; // Rig Object that we are going to move;
    public GameObject TestRigE; // A Rig Object placed correctly to see if it worked correctly

    // Use this for initialization
    void Start()  // We will attach the script to a vive controller and use a trigger pull to move the rig object
    {
        var trackedController = GetComponent<SteamVR_TrackedController>();
        if (trackedController == null)
        {
            trackedController = gameObject.AddComponent<SteamVR_TrackedController>();
        }

        trackedController.TriggerClicked += new ClickedEventHandler(DoClick);
    }

    // Update is called once per frame
    void Update()
    {

    }
    void DoClick(object sender, ClickedEventArgs e)
    {
        Debug.Log(MyName);
        Debug.Log("- - - - - - - - - -< Location >- - - - - - - - - -");
        Debug.Log(StartingPlane.transform.position);
        Debug.Log(TestRig.transform.position);
        Debug.Log(EndingPlane.transform.position);
        Debug.Log(TestRigE.transform.position);
        Debug.Log("- - - - - - - - - -< Angles >- - - - - - - - - -");
        Debug.Log(StartingPlane.transform.eulerAngles);
        Debug.Log(EndingPlane.transform.eulerAngles);
        Debug.Log("- - - - - - - - - -< Move to Neutral >- - - - - - - - - -");
        Vector3 StartingRotation = StartingPlane.transform.rotation.eulerAngles; // Get Starting Plane Rotation in Dergees
        TestRig.transform.RotateAround(StartingPlane.transform.position, Vector3.right, -StartingRotation.x);
        TestRig.transform.RotateAround(StartingPlane.transform.position, Vector3.up,-StartingRotation.y);
        TestRig.transform.RotateAround(StartingPlane.transform.position, Vector3.forward, -StartingRotation.z);
        Debug.Log(StartingRotation);
        Debug.Log(TestRig.transform.rotation.eulerAngles);
        Debug.Log(TestRig.transform.position);
        Debug.Log("- - - - - - - - - -< Relocate to ending >- - - - - - - - - -");
        TestRig.transform.position = TestRig.transform.position - StartingPlane.transform.position + EndingPlane.transform.position;
        Debug.Log(TestRig.transform.position);
        Debug.Log("- - - - - - - - - -< Move to New >- - - - - - - - - -");
        Vector3 EndingRotation = EndingPlane.transform.rotation.eulerAngles; // Get Ending Plane Rotation in Dergees
        TestRig.transform.RotateAround(EndingPlane.transform.position, Vector3.right, EndingRotation.x);
        TestRig.transform.RotateAround(EndingPlane.transform.position, Vector3.up, EndingRotation.y);
        TestRig.transform.RotateAround(EndingPlane.transform.position, Vector3.forward, EndingRotation.z);
        Debug.Log(EndingRotation);
        Debug.Log(TestRig.transform.rotation.eulerAngles);
        Debug.Log(TestRig.transform.position);
    }
}

If you want to make a kind of parent-child position relationship without actually parenting the object, you could make use of a method like this:

I wrote an example code to make things clear:

//The position calculated from the masterObject
private Vector3 relativePosition;
//What position do we want the slaveObject to have in local space?
private Vector3 wantedPosition = new Vector3(0,0,-5);
//The slave object(child)
public Transform slaveObject;
//The master object(parent)
public Transform masterObject;

//Call every frame
void Update()
{
    //Calculate the position
    //What this does:
    //Take the master object and use the local space "wantedPosition" to
    //calculate a world space position. Assign this to "relative position"

    relativePosition = masterObject.TransformPoint(wantedPosition);

    //Set the position of the slave object to this relative position
    slaveObject.position = relativePosition;

    //Make the slave objects look at the master object
    slaveObject.LookAt(masterObject);
}