// Return the raw string of the equation public bool CalculatePlane() { rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; vector12 = new Vector3(0, 0, 0) - new Vector3(rawPt2.Y.Value, rawPt2.X.Value, rawPt2.Z.Value); vector13 = new Vector3(0, 0, 0) - new Vector3(rawPt3.Y.Value, rawPt3.X.Value, rawPt3.Z.Value); //Debug.Log("Vector 12 is: " + vector12 +". Vector13 is: " + vector13); normalVector = Vector3.Cross(vector12, vector13); if (PlaneValid()) { forwardPlane.GetComponent <MeshRenderer>().enabled = true; backwardPlane.GetComponent <MeshRenderer>().enabled = true; // swapped x y // Basic formula of the equation d = rawPt1.Y.Value * normalVector.y + rawPt1.X.Value * normalVector.x + rawPt1.Z.Value * normalVector.z; ptManager.updateEqn(normalVector.x, normalVector.y, normalVector.z, d); return(true); } else { forwardPlane.GetComponent <MeshRenderer>().enabled = false; backwardPlane.GetComponent <MeshRenderer>().enabled = false; ptManager.updateEqn(); return(false); } }
void Awake() { solver = new AK.ExpressionSolver(); expr = new AK.Expression(); vertices = new List <Vector3>(); stepSize = defaultStepSize; if (ptManager != null && ptManager2D == null) { if (ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } } if (ptManager == null && ptManager2D != null) { if (ptManager2D != null && ptManager2D.ptSet != null) { ptSetExist = true; rawPt1 = ptManager2D.ptSet.ptCoords["pt1"]; rawPt2 = ptManager2D.ptSet.ptCoords["pt2"]; } } }
// Return the determinant calculation public bool CalculatePlane() //previously returned bool { if (ptManager != null) { rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; // Calculating the determinant float determinant = rawPt1.X.Value * DeterminantTwoD(rawPt2.Y.Value, rawPt3.Y.Value, rawPt2.Z.Value, rawPt3.Z.Value) - rawPt2.X.Value * DeterminantTwoD(rawPt1.Y.Value, rawPt3.Y.Value, rawPt1.Z.Value, rawPt3.Z.Value) + rawPt3.X.Value * DeterminantTwoD(rawPt1.Y.Value, rawPt2.Y.Value, rawPt1.Z.Value, rawPt2.Z.Value); ptManager.updateDet(determinant); } else { rawPt1 = ptManager2D.ptSet.ptCoords["pt1"]; rawPt2 = ptManager2D.ptSet.ptCoords["pt2"]; float determinant = DeterminantTwoD(rawPt1.X.Value, rawPt2.X.Value, rawPt1.Y.Value, rawPt2.Y.Value); ptManager2D.updateDet(determinant); } return(true); }
public float[] PtCoordToArray(PtCoord pt) { float[] array = new float[3]; array[0] = pt.X.Value; array[1] = pt.Y.Value; array[2] = pt.Z.Value; return(array); }
public Vector3 GenerateVector(PtCoord pt1, PtCoord pt2) { Vector3 result = Vector3.zero; result.x = pt2.X.Value - pt1.X.Value; result.y = pt2.Y.Value - pt1.Y.Value; result.z = pt2.Z.Value - pt1.Z.Value; return(result); }
public void AddPtCoord(string variable, PtCoord ptCoord) { if (ptCoord != null) { if (ptCoords.ContainsKey(variable)) { ptCoords[variable] = ptCoord; } else { ptCoords.Add(variable, ptCoord); } } }
void Update() { if (!ptSetExist && ptManager != null && ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } plane.LookAt(lookAtTarget); pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"; pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"; pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")"; //pt2Label.text = string.Format("({0:F3},{1:F3},{2:F3})", rawPt2.X.Value, rawPt2.Y.Value, rawPt2.Z.Value); var sharedMaterial = forwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } sharedMaterial = backwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } }
// Return the raw string of the equation public bool CalculatePlane() { rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; //vector12 = GenerateVector(rawPt1, rawPt2); //vector13 = GenerateVector(rawPt1, rawPt3); //Debug.Log("Vector 12 is: " + vector12 +". Vector13 is: " + vector13); normalVector = Vector3.Cross(vector12, vector13); if (PlaneValid()) { forwardPlane.GetComponent <MeshRenderer>().enabled = true; backwardPlane.GetComponent <MeshRenderer>().enabled = true; // Basic formula of the equation //d = rawPt1.X.Value * normalVector.x + rawPt1.Y.Value * normalVector.y + rawPt1.Z.Value * normalVector.z; // string[] formattedValue = roundString(new float[] {normalVector.x, normalVector.y, normalVector.z}); // // Formatting equation // if (formattedValue[1][0] != '-') formattedValue[1] = '+' + formattedValue[1]; // if (formattedValue[2][0] != '-') formattedValue[2] = '+' + formattedValue[2]; // rawEquation = formattedValue[0] + "x" + formattedValue[1] + "y" + formattedValue[2] + "z=" + d; //ptManager.updateEqn(normalVector.x, normalVector.y, normalVector.z, d); return(true); } else { //forwardPlane.GetComponent<MeshRenderer>().enabled = false; //backwardPlane.GetComponent<MeshRenderer>().enabled = false; // rawEquation = "Invalid Plane"; //ptManager.updateEqn(); return(false); } //Debug.Log("Normal vector is: " + normalVector); }
void Update() { if (ptManager != null) { if (!ptSetExist && ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } } else { if (!ptSetExist && ptManager2D != null && ptManager2D.ptSet != null) { ptSetExist = true; rawPt1 = ptManager2D.ptSet.ptCoords["pt1"]; rawPt2 = ptManager2D.ptSet.ptCoords["pt2"]; } } plane.LookAt(lookAtTarget); if (pt3Label != null) { pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"; pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"; pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")"; } else { pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + ")"; pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + ")"; } //pt2Label.text = string.Format("({0:F3},{1:F3},{2:F3})", rawPt2.X.Value, rawPt2.Y.Value, rawPt2.Z.Value); //TAG }
void Update() { if (!ptSetExist && ptManager != null && ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } // Debug.Log("lookAtTarget: "+ lookAtTarget.position + " " + plane.gameObject.name); // Debug.Log("lookAtTargetT: "+ lookAtTargetT.position + " " + planeT.gameObject.name); //plane.localPosition = ScaledPoint(new Vector3(0, 0, 0)); //Debug.Log("(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"); //Debug.Log("(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"); //pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"; //pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"; //pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")"; //pt2Label.text = string.Format("({0:F3},{1:F3},{2:F3})", rawPt2.X.Value, rawPt2.Y.Value, rawPt2.Z.Value); var sharedMaterial = forwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } sharedMaterial = backwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } sharedMaterial = forwardPlaneT.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } sharedMaterial = backwardPlaneT.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } GetLocalPoint(); ApplyGraphAdjustment(); }
public Vector3 PtCoordToVector(PtCoord pt) { return(new Vector3(pt.X.Value, pt.Y.Value, pt.Z.Value)); }
void Update() { if (!ptSetExist && ptManager != null && ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } // Debug.Log(MatrixYFX.forLine); if (transform.gameObject.name == "PlaneExpression_null") { // p1 = MatrixYFX.n1; // scaledPt1 = ScaledPoint(p1); // point1.localPosition = scaledPt1; // p2 = MatrixYFX.n2; // scaledPt2 = ScaledPoint(p2); // point2.localPosition = scaledPt2; // p3 = MatrixYFX.n3; // scaledPt3 = ScaledPoint(p3); // point3.localPosition = scaledPt3; // p1Line = MatrixYFX.c1T; if (MatrixYFX.mRank == 2) { p1Line = getBasisVectors.n1; scaledPt1Line = ScaledPoint(p1Line); point1Line.localPosition = scaledPt1Line; // p2Line = MatrixYFX.c2T; p2Line = getBasisVectors.n2; scaledPt2Line = ScaledPoint(p2Line); point2Line.localPosition = scaledPt2Line; // p3Line = MatrixYFX.c3T; p3Line = getBasisVectors.n3; scaledPt3Line = ScaledPoint(p3Line); point3Line.localPosition = scaledPt3Line; } if (MatrixYFX.mRank == 1) { p1Line = getBasisVectors.c1T; scaledPt1Line = ScaledPoint(p1Line); point1Line.localPosition = scaledPt1Line; // p2Line = MatrixYFX.c2T; p2Line = getBasisVectors.c2T; scaledPt2Line = ScaledPoint(p2Line); point2Line.localPosition = scaledPt2Line; // p3Line = MatrixYFX.c3T; p3Line = getBasisVectors.c3T; scaledPt3Line = ScaledPoint(p3Line); point3Line.localPosition = scaledPt3Line; } lookAtTarget.localPosition = ScaledPoint(p1Line); line.LookAt(lookAtTarget); line.localPosition = ScaledPoint(new Vector3(0, 0, 0)); lineT.LookAt(lookAtTarget); lineT.localPosition = ScaledPoint(new Vector3(0, 0, 0)); } if (transform.gameObject.name == "PlaneExpression_col") { // p1 = MatrixYFX.c1; // scaledPt1 = ScaledPoint(p1); // point1.localPosition = scaledPt1; // p2 = MatrixYFX.c2; // scaledPt2 = ScaledPoint(p2); // point2.localPosition = scaledPt2; // p3 = MatrixYFX.c3; // scaledPt3 = ScaledPoint(p3); // point3.localPosition = scaledPt3; if (MatrixYFX.mRank == 2) { p1Line = getBasisVectors.n1T; // p1Line = MatrixYFX.c1; scaledPt1Line = ScaledPoint(p1Line); point1Line.localPosition = scaledPt1Line; p2Line = getBasisVectors.n2T; // p2Line = MatrixYFX.c2; scaledPt2Line = ScaledPoint(p2Line); point2Line.localPosition = scaledPt2Line; p3Line = getBasisVectors.n3T; // p3Line = MatrixYFX.c3; scaledPt3Line = ScaledPoint(p3Line); point3Line.localPosition = scaledPt3Line; } if (MatrixYFX.mRank == 1) { p1Line = getBasisVectors.c1; scaledPt1Line = ScaledPoint(p1Line); point1Line.localPosition = scaledPt1Line; // p2Line = MatrixYFX.c2T; p2Line = getBasisVectors.c2; scaledPt2Line = ScaledPoint(p2Line); point2Line.localPosition = scaledPt2Line; // p3Line = MatrixYFX.c3T; p3Line = getBasisVectors.c3; scaledPt3Line = ScaledPoint(p3Line); point3Line.localPosition = scaledPt3Line; } lookAtTarget.localPosition = ScaledPoint(p1Line); line.LookAt(lookAtTarget); line.localPosition = ScaledPoint(new Vector3(0, 0, 0)); lineT.LookAt(lookAtTarget); lineT.localPosition = ScaledPoint(new Vector3(0, 0, 0)); } // p1 = MatrixYFX.c1; // p2 = MatrixYFX.c2; // p3 = MatrixYFX.c3; // scaledPt1 = ScaledPoint(p1); // point1.localPosition = scaledPt1; // //scaledPt2 = ScaledPoint(p2); // //point2.localPosition = scaledPt2; // scaledPt3 = ScaledPoint(p3); // point3.localPosition = scaledPt3; pt1Label.text = "(" + p1.x + "," + p1.y + "," + p1.z + ")"; pt2Label.text = "(" + p2.x + "," + p2.y + "," + p2.z + ")"; pt3Label.text = "(" + p3.x + "," + p3.y + "," + p3.z + ")"; // lookAtTarget.localPosition = ScaledPoint(p1); // line.LookAt(lookAtTarget); // line.localPosition = ScaledPoint(new Vector3(0, 0, 0)); // lookAtTargetT.localPosition = ScaledPoint(p1Line); // lineT.LookAt(lookAtTargetT); // lineT.localPosition = ScaledPoint(new Vector3(0, 0, 0)); //pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"; //pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"; //pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")"; //pt2Label.text = string.Format("({0:F3},{1:F3},{2:F3})", rawPt2.X.Value, rawPt2.Y.Value, rawPt2.Z.Value); var sharedMaterial = forwardLine.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } sharedMaterial = forwardLineT.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } ApplyGraphAdjustment(); }
void Update() { if (!ptSetExist && ptManager != null && ptManager.ptSet != null) { ptSetExist = true; rawPt1 = ptManager.ptSet.ptCoords["pt1"]; rawPt2 = ptManager.ptSet.ptCoords["pt2"]; rawPt3 = ptManager.ptSet.ptCoords["pt3"]; } usersPoint = PtCoordToVector(rawPt1); plane.LookAt(lookAtPlaneTarget); //TURN OFF AND ON POINT VISABILITY point1.GetComponent <MeshRenderer>().enabled = false; point2.GetComponent <MeshRenderer>().enabled = false; point3.GetComponent <MeshRenderer>().enabled = false; //HERES YOUR COORD TEXT pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")"; //pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")"; //pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")"; scaledPt1 = ScaledPoint(PtCoordToVector(rawPt1)); point1.localPosition = scaledPt1; scaledPt2 = ScaledPoint(PtCoordToVector(rawPt2)); point2.localPosition = scaledPt2; scaledPt3 = ScaledPoint(PtCoordToVector(rawPt3)); point3.localPosition = scaledPt3; xAxis.localPosition = ScaledPoint(center); yAxis.localPosition = ScaledPoint(center); zAxis.localPosition = ScaledPoint(center); //projectionAxis lookAtAxisTarget.localPosition = ScaledPoint(PtCoordToVector(rawPt2)); axisline.localPosition = ScaledPoint(center); axisline.LookAt(lookAtAxisTarget); var sharedMaterial2 = forwardAxisLine.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial2.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial2.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial2.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } if ((new Vector3(0, 0, 0)) == PtCoordToVector(rawPt2)) { forwardAxisLine.GetComponent <MeshRenderer>().enabled = false; } //if there is no 3rd component (line) else if (new Vector3(0, 0, 0) == PtCoordToVector(rawPt3)) { forwardAxisLine.GetComponent <MeshRenderer>().enabled = true; projectedResult = Vector3.Project(PtCoordToVector(rawPt1), PtCoordToVector(rawPt2)); ptManager.manageText(); } //if there is a 3rd coord (subspace) else { forwardAxisLine.GetComponent <MeshRenderer>().enabled = false; projectedResult = Vector3.ProjectOnPlane(PtCoordToVector(rawPt1), normalVector); ptManager.manageText(); } var sharedMaterial3 = forwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial3.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial3.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial3.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } var sharedMaterial = backwardPlane.GetComponent <MeshRenderer>().sharedMaterial; sharedMaterial.SetInt("_planeClippingEnabled", 1); for (int i = 0; i < 6; i++) { sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position); //plane normal vector is the rotated 'up' vector. sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up); } }
public void AddPtCoord(string variable, AxisCoord x, AxisCoord y, AxisCoord z) { PtCoord ptCoord = new PtCoord(x, y, z); AddPtCoord(variable, ptCoord); }
public SerializablePtCoord(PtCoord ptCoord) { X = new SerializableAxisCoord(ptCoord.X); Y = new SerializableAxisCoord(ptCoord.Y); Z = new SerializableAxisCoord(ptCoord.Z); }
public PtCoord(PtCoord toCopy) { X = new AxisCoord(toCopy.X); Y = new AxisCoord(toCopy.Y); Z = new AxisCoord(toCopy.Z); }