private void OnTriggerEnter(Collider other) { if (other.name.Contains("Intersection")) { if (other.name.Contains("Start")) { arrived = false; } IntersectionProperties temp = other.gameObject.GetComponent <IntersectionProperties>(); if (nextID == temp.intersectionID) { nextPath = temp.nextPath; nextID = temp.nextID; if (nextPath != null) { nextTurnSign = temp.nextTurnSign; currentIndication = temp.nextTurnSign; if (currentIndication == 's') { naviRenderer.material = arrowStraight; } else if (currentIndication == 'r') { naviRenderer.material = arrowRight; } else if (currentIndication == 'l') { naviRenderer.material = arrowLeft; } else { naviRenderer.material = transparent; currentIndication = 't'; } mySyncScript.RpcUpdateChar(myDirectionTag, currentIndication); changePath = true; } else { nextTurnSign = '\0'; currentIndication = 'z'; naviRenderer.material = transparent; } } else if (nextID == -1) { nextID = 0; arrived = true; } } }
/// <summary> /// Initializes a new instance of the <see cref="IntersectionLinearCircular" /> class. /// </summary> /// <param name="linearCurve">The linear curve.</param> /// <param name="circularCurve">The circular curve.</param> public IntersectionLinearCircular(LinearCurve linearCurve, CircularCurve circularCurve) : base(linearCurve, circularCurve) { _properties = new IntersectionProperties(linearCurve, circularCurve); }
/// <summary> /// The coordinate of the intersection of two curves. /// </summary> /// <param name="linearCurve">The linear curve.</param> /// <param name="circularCurve">The circular curve.</param> /// <param name="_properties">Pre-calculated properties to be used for convenience.</param> /// <returns>CartesianCoordinate[].</returns> private static CartesianCoordinate[] _intersectionCoordinates(LinearCurve linearCurve, CircularCurve circularCurve, IntersectionProperties _properties) { if (!_areIntersecting(linearCurve, circularCurve, _properties)) { return(new CartesianCoordinate[0]); } double D = _properties.D; double dx = _properties.dx; double dy = _properties.dy; double dr = _properties.dr; double incidenceDeltaSqrt = _properties.IncidenceDelta.Sqrt(); double[] xIntersection = Numbers.PlusMinus(D * dy / dr.Squared(), (dy.Sign() * dx / dr.Squared()) * incidenceDeltaSqrt); double[] yIntersection = Numbers.PlusMinus(-1 * D * dx / dr.Squared(), (dy.Abs() / dr.Squared()) * incidenceDeltaSqrt); Transformations converter = _properties.Transformations; if (_areTangent(linearCurve, circularCurve, _properties)) { return(new CartesianCoordinate[] { converter.TransformToGlobal(new CartesianCoordinate(xIntersection[0], yIntersection[0])) }); } return(new CartesianCoordinate[] { converter.TransformToGlobal(new CartesianCoordinate(xIntersection[0], yIntersection[0])), converter.TransformToGlobal(new CartesianCoordinate(xIntersection[1], yIntersection[1])) }); }
/// <summary> /// The curves intersect. /// </summary> /// <param name="linearCurve">The linear curve.</param> /// <param name="circularCurve">The circular curve.</param> /// <param name="_properties">Pre-calculated properties to be used for convenience.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private static bool _areIntersecting(LinearCurve linearCurve, CircularCurve circularCurve, IntersectionProperties _properties) { return(_properties.IncidenceDelta.IsGreaterThanOrEqualTo(0, Generics.GetTolerance(linearCurve, circularCurve))); }