public void getVectorFromEdge2EdgeWithAngleTest6() { AdjacentEdge target = new AdjacentEdge(new Point(0, 0, 1), new Point(0, 0, -1)); // TODO: 初始化为适当的值 Point beginPoint = new Point(0, 0, -1); // TODO: 初始化为适当的值 double angle = 60; // TODO: 初始化为适当的值 AdjacentEdge targetEdge = new AdjacentEdge(new Point(1, 1, 0), new Point(1, -1, 0)); // TODO: 初始化为适当的值 //RayInfo actual; List <RayInfo> list = new List <RayInfo>(); list = target.getVectorFromEdge2EdgeWithAngle(beginPoint, angle, targetEdge); //actual = target.getVectorFromEdge2EdgeWithAngle(beginPoint, angle, targetEdge); Assert.IsTrue(list.Count == 0); }
public void getVectorFromEdge2EdgeWithAngleTest3() { AdjacentEdge target = new AdjacentEdge(new Point(0, 0, 1), new Point(0, 0, -1)); // TODO: 初始化为适当的值 Point beginPoint = new Point(0, 0, 0); // TODO: 初始化为适当的值 double angle = 135; // TODO: 初始化为适当的值 AdjacentEdge targetEdge = new AdjacentEdge(new Point(-1, 0, 1), new Point(-1, 0, -1)); // TODO: 初始化为适当的值 RayInfo expected = new RayInfo(new Point(-1, 0, 1), new SpectVector(-1, 0, 1)); // TODO: 初始化为适当的值 RayInfo actual; List <RayInfo> list = new List <RayInfo>(); list = target.getVectorFromEdge2EdgeWithAngle(beginPoint, angle, targetEdge); actual = list[0]; Assert.IsTrue(Math.Abs(expected.Origin.X - actual.Origin.X) < 0.000001 && Math.Abs(expected.Origin.Y - actual.Origin.Y) < 0.000001 && Math.Abs(expected.Origin.Z - actual.Origin.Z) < 0.000001 && Math.Abs(expected.RayVector.a - actual.RayVector.a) < 0.000001 && Math.Abs(expected.RayVector.b - actual.RayVector.b) < 0.000001 && Math.Abs(expected.RayVector.c - actual.RayVector.c) < 0.000001); }
/// <summary> /// 计算两次绕射的绕射点 /// </summary> /// <param name="edge1">第一条绕射棱</param> /// <param name="edge2">第二条绕射棱</param> /// <param name="beginPoint">第一条绕射棱前的点</param> /// <param name="endPoint">第二条绕射棱后的点</param> /// <returns>用List的形式返回两个点的坐标</returns> private List <Point> GetTwoDiffractionPoints(AdjacentEdge edge1, AdjacentEdge edge2, Point beginPoint, Point endPoint) { Point p1 = edge1.GetDiffractionPoint(beginPoint, edge2.StartPoint); Point p2 = edge1.GetDiffractionPoint(beginPoint, edge2.EndPoint); Point p21 = edge2.StartPoint; Point p22 = edge2.EndPoint; AdjacentEdge tempLine = new AdjacentEdge(new Point(-10000 * edge2.LineVector.a + endPoint.X, -10000 * edge2.LineVector.b + endPoint.Y, -10000 * edge2.LineVector.c + endPoint.Z), new Point(10000 * edge2.LineVector.a + endPoint.X, 10000 * edge2.LineVector.b + endPoint.Y, 10000 * edge2.LineVector.c + endPoint.Z), edge2.LineVector); double angle1 = SpectVector.VectorPhase(new SpectVector(p1, edge2.StartPoint), edge2.LineVector); double angle2 = SpectVector.VectorPhase(new SpectVector(p2, edge2.EndPoint), edge2.LineVector); SpectVector sp1 = edge2.getVectorFromEdge2EdgeWithAngle(p1, angle1, tempLine).RayVector; SpectVector sp2 = edge2.getVectorFromEdge2EdgeWithAngle(p2, angle2, tempLine).RayVector; RayInfo ray1 = new RayInfo(p1, sp1); RayInfo ray2 = new RayInfo(p2, sp2); Point dropFoot1 = ray1.getDropFoot(endPoint); Point dropFoot2 = ray2.getDropFoot(endPoint); double distance1 = endPoint.GetDistance(dropFoot1); double distance2 = endPoint.GetDistance(dropFoot2); List <Point> diffractPoints = new List <Point>(); int i = 20; while (i-- > 0) { if (distance1 < 0.00001) { diffractPoints.Add(p1); diffractPoints.Add(p21); break; } if (distance2 < 0.00001) { diffractPoints.Add(p2); diffractPoints.Add(p22); break; } Point tempPoint = new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2); double tempAngle1 = SpectVector.VectorPhase(new SpectVector(beginPoint, tempPoint), edge1.LineVector); RayInfo tempRay1 = edge1.getVectorFromEdge2EdgeWithAngle(tempPoint, tempAngle1, edge2); double tempAngle2 = SpectVector.VectorPhase(tempRay1.RayVector, edge2.LineVector); RayInfo tempRay2 = edge2.getVectorFromEdge2EdgeWithAngle(tempRay1.Origin, tempAngle2, tempLine); Point tempDropFoot = new RayInfo(tempRay1.Origin, tempRay2.RayVector).getDropFoot(endPoint); double tempDistance = tempDropFoot.GetDistance(endPoint); SpectVector tempSP1 = new SpectVector(dropFoot1, edge2.StartPoint); SpectVector tempSP2 = new SpectVector(dropFoot2, edge2.StartPoint); SpectVector tempSP3 = new SpectVector(tempDropFoot, edge2.StartPoint); SpectVector tempSP4 = new SpectVector(endPoint, edge2.StartPoint); double endAngle12 = SpectVector.VectorPhase(tempSP1, tempSP2); double endAngle13 = SpectVector.VectorPhase(tempSP1, tempSP3); double endAngle23 = SpectVector.VectorPhase(tempSP2, tempSP3); double endAngle14 = SpectVector.VectorPhase(tempSP1, tempSP4); if (endAngle14 > endAngle13) { p1 = tempPoint; angle1 = tempAngle2; p21 = tempRay1.Origin; dropFoot1 = tempDropFoot; distance1 = tempDistance; } else if (endAngle14 < endAngle13) { p2 = tempPoint; angle2 = tempAngle2; p22 = tempRay1.Origin; dropFoot2 = tempDropFoot; distance2 = tempDistance; } else { if (distance1 < 0.1) { diffractPoints.Add(p1); diffractPoints.Add(p21); break; } if (distance2 < 0.1) { diffractPoints.Add(p2); diffractPoints.Add(p22); break; } throw new Exception("二次绕射反向问题"); } } return(diffractPoints); }