public override void TangentToTangent(List <Turn> turnList) { Vector3 preNormal = Vector3.Cross(t1, Vector3.up); Vector3 dir = (current - prev); Vector3 pos = dir * 0.5F + prev; dir = Vector3.Cross(dir, Vector3.up); bool didIntersect; circleCenter = VectorMath.LineDirIntersectionPointXZ(prev, preNormal, pos, dir, out didIntersect); if (!didIntersect) { return; } gamma1 = Atan2(prev - circleCenter); gamma2 = Atan2(current - circleCenter); clockwise = !VectorMath.RightOrColinearXZ(circleCenter, prev, prev + t1); double beta = clockwise ? ClockwiseAngle(gamma1, gamma2) : CounterClockwiseAngle(gamma1, gamma2); beta = GetLengthFromAngle(beta, (circleCenter - current).magnitude); turnList.Add(new Turn((float)beta, this, 0)); }
public override void TangentToTangent(List<AdvancedSmooth.Turn> turnList) { Vector3 dir = Vector3.Cross(AdvancedSmooth.TurnConstructor.t1, Vector3.up); Vector3 vector = AdvancedSmooth.TurnConstructor.current - AdvancedSmooth.TurnConstructor.prev; Vector3 start = vector * 0.5f + AdvancedSmooth.TurnConstructor.prev; vector = Vector3.Cross(vector, Vector3.up); bool flag; this.circleCenter = VectorMath.LineDirIntersectionPointXZ(AdvancedSmooth.TurnConstructor.prev, dir, start, vector, out flag); if (!flag) { return; } this.gamma1 = base.Atan2(AdvancedSmooth.TurnConstructor.prev - this.circleCenter); this.gamma2 = base.Atan2(AdvancedSmooth.TurnConstructor.current - this.circleCenter); this.clockwise = !VectorMath.RightOrColinearXZ(this.circleCenter, AdvancedSmooth.TurnConstructor.prev, AdvancedSmooth.TurnConstructor.prev + AdvancedSmooth.TurnConstructor.t1); double num = (!this.clockwise) ? base.CounterClockwiseAngle(this.gamma1, this.gamma2) : base.ClockwiseAngle(this.gamma1, this.gamma2); num = base.GetLengthFromAngle(num, (double)(this.circleCenter - AdvancedSmooth.TurnConstructor.current).magnitude); turnList.Add(new AdvancedSmooth.Turn((float)num, this, 0)); }
public override void TangentToTangent(List <AdvancedSmooth.Turn> turnList) { bool flag; Vector3 vector = Vector3.Cross(AdvancedSmooth.TurnConstructor.t1, Vector3.up); Vector3 lhs = AdvancedSmooth.TurnConstructor.current - AdvancedSmooth.TurnConstructor.prev; Vector3 vector3 = ((Vector3)(lhs * 0.5f)) + AdvancedSmooth.TurnConstructor.prev; lhs = Vector3.Cross(lhs, Vector3.up); this.circleCenter = VectorMath.LineDirIntersectionPointXZ(AdvancedSmooth.TurnConstructor.prev, vector, vector3, lhs, out flag); if (flag) { this.gamma1 = base.Atan2(AdvancedSmooth.TurnConstructor.prev - this.circleCenter); this.gamma2 = base.Atan2(AdvancedSmooth.TurnConstructor.current - this.circleCenter); this.clockwise = !VectorMath.RightOrColinearXZ(this.circleCenter, AdvancedSmooth.TurnConstructor.prev, AdvancedSmooth.TurnConstructor.prev + AdvancedSmooth.TurnConstructor.t1); double angle = !this.clockwise ? base.CounterClockwiseAngle(this.gamma1, this.gamma2) : base.ClockwiseAngle(this.gamma1, this.gamma2); Vector3 vector4 = this.circleCenter - AdvancedSmooth.TurnConstructor.current; angle = base.GetLengthFromAngle(angle, (double)vector4.magnitude); turnList.Add(new AdvancedSmooth.Turn((float)angle, this, 0)); } }
public static Vector3 IntersectionPointOptimized(Vector3 start1, Vector3 dir1, Vector3 start2, Vector3 dir2, out bool intersects) { return(VectorMath.LineDirIntersectionPointXZ(start1, dir1, start2, dir2, out intersects)); }