/// <summary> /// Calculate all points' coordinates /// </summary> public override void CalculatePoints() { if (ListParamsValidation == null) { ListParamsValidation = new List <ParamValidationInfo>(); } ListParamsValidation.Clear(); // points double gammaMradmec2 = GammaM / 180 * alpha; xA = RGap * Math.Cos(gammaMradmec2); yA = RGap * Math.Sin(gammaMradmec2); xB = Rrotor * Math.Cos(gammaMradmec2); yB = Rrotor * Math.Sin(gammaMradmec2); // point far right of rotors xR = RGap; yR = 0; xS = RGap * Math.Cos(alpha); yS = RGap * Math.Sin(alpha); xRR = Rrotor; yRR = 0; xSS = Rrotor * Math.Cos(alpha); ySS = Rrotor * Math.Sin(alpha); // isPointsCoordCalculated = true; }
/// <summary> /// Calculate all points' coordinates /// </summary> public override void CalculatePoints() { if (ListParamsValidation == null) { ListParamsValidation = new List <ParamValidationInfo>(); } ListParamsValidation.Clear(); double a = Math.Tan(alpha); double b = Rib / 2 * Math.Cos(alpha); xA = (a * b + Math.Sqrt(a * a * R1 * R1 + R1 * R1 - b * b)) / (a * a + 1); yA = a * xA - b; xB = xA - HRib * Math.Cos(alpha); yB = yA - HRib * Math.Sin(alpha); xJ = DiaYoke / 2 + O2; yJ = O1 / 2; alphaM = Math.Atan((yB - yJ) / (xB - xJ)); xK0 = xJ - O1 / (2 * Math.Tan(alphaM)) + B1 / Math.Sin(alphaM); // calc K depends on poletype switch (Poletype) { case PoleType.MiddleSteelBridgeTrapezoid: //need to limit O1, xJ, alphaM or something collides (require yK>=0) double oldO1 = O1; while (true) { xK = xJ + B1 * Math.Sin(alphaM); yK = yJ - B1 * Math.Cos(alphaM); if (yK < 0) { O1 += 0.01; } else { break; } //recalculate J,alphaM,xK0 because O1 changed yJ = O1 / 2; alphaM = Math.Atan((yB - yJ) / (xB - xJ)); xK0 = xJ - O1 / (2 * Math.Tan(alphaM)) + B1 / Math.Sin(alphaM); } if (oldO1 != O1) { String msg = "O1 changed from:" + oldO1 + " to " + O1; addValidationInfo("O1", msg, ParamValidationInfo.MessageType.Warning); //log.Warn(msg); } break; case PoleType.MiddleSteelBridgeRectangle: xK = xJ + B1 / Math.Sin(alphaM); yK = yJ; break; case PoleType.MiddleAir: //5 default: xK = xK0; yK = 0; break; } //limit the Dminmag or it collides double previousDmm = Dminmag; double dmmm = O1 - 2 * B1 * Math.Cos(alphaM); if (Dminmag < dmmm) { Dminmag = dmmm; } if (Poletype == PoleType.MiddleSteelBridgeRectangle && Dminmag < O1) { Dminmag = O1; } if (previousDmm != Dminmag) { String msg = "Dminmag changed from:" + previousDmm + " to " + Dminmag; addValidationInfo("Dminmag", msg, ParamValidationInfo.MessageType.Warning); //log.Warn(msg); } xI = Dminmag / (2 * Math.Tan(alphaM)) + xK0; yI = Dminmag / 2; xH = xI - B1 * Math.Sin(alphaM); yH = yI + B1 * Math.Cos(alphaM); xG = xI - ThickMag * Math.Sin(alphaM); yG = yI + ThickMag * Math.Cos(alphaM); //check WidthMag limits double b_ = xI * Math.Cos(alphaM) + yI * Math.Sin(alphaM); double c_ = xI * xI + yI * yI - R1 * R1; double maxWidthMag = 2 * Math.Sqrt(b_ * b_ - c_) - 2 * b_; if (double.IsNaN(maxWidthMag)) { maxWidthMag = 0; } if (WidthMag > maxWidthMag) { addValidationInfo("WidthMag", "WidthMag is too big. Max: " + maxWidthMag, ParamValidationInfo.MessageType.Error); //log.Error("WidthMag maximum allowed:" + maxWidthMag); } xF = xI + WidthMag / 2 * Math.Cos(alphaM); yF = yI + WidthMag / 2 * Math.Sin(alphaM); xE = xF - B1 * Math.Sin(alphaM); yE = yF + B1 * Math.Cos(alphaM); xD = xF - ThickMag * Math.Sin(alphaM); yD = yF + ThickMag * Math.Cos(alphaM); double c = Math.Tan(alphaM); double d = Math.Tan(alphaM) * xK0; xC = (c * d + Math.Sqrt(c * c * R1 * R1 + R1 * R1 - d * d)) / (c * c + 1); yC = c * xC - d; //open angle of magnet (eletrical degree) gammaMedeg = 2 * Math.Atan(yC / xC) * p * 180 / Math.PI; // point far right of rotors xR = Rrotor; yR = 0; xS = Rrotor * Math.Cos(alpha); yS = Rrotor * Math.Sin(alpha); // isPointsCoordCalculated = true; }