public static void drawSimpleSpiderGizmo(JunctionSimpleSpider junctionSimpleSpider, float size, Vector3 posAbs, Vector3 targetAbs)
 {
     UnityEditorUtils.cylinder(posAbs, MUtil.qToAxesXZ(junctionSimpleSpider.axisAbs, targetAbs), 1, 10, 0, 1 * size, 0.1f * size, 0.1f * size);
     UnityEditorUtils.cylinder(posAbs,
                               MUtil.qToAxesXZ(junctionSimpleSpider.secondaryAxisAbs, junctionSimpleSpider.axisAbs),
                               1, 10, 0, 1 * size * 0.3f, 0.1f * size * 0.5f, 0.1f * size * 0.5f);
 }
        public void fillOrigins(Vector3 xA1, float ar, Quaternion fromRot, Vector3 xB1, float br, Quaternion toRot, List <Vector3> poss, List <Quaternion> rots)
        {
            Vector3 vA = fromRot.rotate(new Vector3(ar, 0, 0));
            Vector3 vB = toRot.rotate(new Vector3(-br, 0, 0));

            Vector3 xA2 = xA1 + vA;
            Vector3 xB2 = xB1 + vB;

            poss[0] = xA1;

            Vector3 Z = fromRot.rotate(new Vector3(0, 0, 1));
//            Vector3 Z = -vA.crossProduct(xB1 - xA1);
            Quaternion startRotDif = Quaternion.identity;
            Quaternion endRotDif   = Quaternion.identity;

            if (simpleOrientation)
            {
                rots[0] = MUtil.qToAxesXZ(vA, Z);
            }
            else
            {
                startRotDif = fromRot.rotSub(MUtil.qToAxesXZ(vA, Z));
                endRotDif   = toRot.rotSub(MUtil.qToAxesXZ(-vB, Z));
                rots[0]     = fromRot;
            }

            Vector3 lastPos = poss[0];

            for (int i = 1; i < poss.Count; i++)
            {
                float progress = (float)i / (poss.Count - 1);

                Vector3 bb         = xA2.mix(xB2, progress);
                Vector3 currentPos = xA1.mix(bb, progress).mix(bb.mix(xB1, progress), progress);
                poss[i] = currentPos;
                rots[i] = MUtil.qToAxesXZ(currentPos - lastPos, Z);
                if (!simpleOrientation)
                {
                    rots[i] = rots[i] * startRotDif.nlerp(endRotDif, progress);
                }

                lastPos = currentPos;
            }
            if (!simpleOrientation)
            {
                rots[rots.Count - 1] = toRot;
            }
        }
        public static void draw2DLeg(Vector3 X, Vector3 Y, Vector3 pos, float size)
        {
//            Vector3 Z = X.crossProduct(Y);
//            X = Y.crossProduct(Z).normalized;
//                Gizmos.DrawLine(h.transform.position, h.transform.position + X * 0.2f + Y * 0.2f);
//                Gizmos.DrawLine(h.transform.position + X * 0.2f + Y * 0.2f, h.transform.position + X * 0.4f);
            Quaternion rot = MUtil.qToAxesXZ(X, Y);

            GL.PushMatrix();
            GL.LoadProjectionMatrix(Camera.current.projectionMatrix);

            GL.MultMatrix(Matrix4x4.TRS(
                              pos,
                              rot * Quaternion.AngleAxis(-45, Vector3.up), new Vector3(size, size, size)));
            diamond2d();
            GL.MultMatrix(Matrix4x4.TRS(
                              pos + rot.rotate(new Vector3(size * MyMath.cos(MyMath.PI / 4), 0, size * MyMath.cos(MyMath.PI / 4))),
                              rot * Quaternion.AngleAxis(45, Vector3.up), new Vector3(size, size, size)));
            diamond2d();

            GL.PopMatrix();
        }