public static dynamic GetTSObject(ControlPlane dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
private void ReadControlPlaneAllFType(ControlPlane cpR, ControlPlane cpL, bool flagMessage) { cpR.gamma_h = MathTool.DegToRad(ReadDblValue("gamma_H", flagMessage)); cpR.hc = ReadVector("HC", flagMessage); if (cpR.type != 0) { cpL.gamma_h = cpR.gamma_h; cpL.hc = cpR.hc; } }
// Use this for initialization void Start() { planes = new ControlPlane(); // Register Global Message 1 GlobalSignal.GlobalMsg1 = MessageManager.CreatMessage(); MessageManager.RegisterHander(GlobalSignal.GlobalMsg1, this.simulateAndSave); // Register Global Message 2 GlobalSignal.GlobalMsg2 = MessageManager.CreatMessage(); MessageManager.RegisterHander(GlobalSignal.GlobalMsg2, this.restartSimulation); //GlobalSignal.LoadDataToTable ("/Results/iso", "txt", 0); //GlobalSignal.SaveTableToFile ("testCorse.txt", 0); }
static void Main(string[] args) { int THREADS = 2; int OBJECTS = 2; if (args.Length != 0) { for (int i = 0; i < args.Length; i++) { if (args[i] == "--threads") { i++; if (int.Parse(args[i]) > THREADS) { THREADS = int.Parse(args[i]); } } if (args[i] == "--objects") { i++; OBJECTS = int.Parse(args[i]); } } } Console.WriteLine("Using {0} threads", THREADS); Console.WriteLine("Creating {0} objects", OBJECTS); Thread.Sleep(1000); Random rand = new Random(); System.Collections.ArrayList objs = new System.Collections.ArrayList(); PhysicsSimulation m_Physics = new PhysicsSimulation(THREADS); for (int i = 0; i < OBJECTS; i++) { Spheroid m_Spheroid = new Spheroid( new Vector3(rand.Next(-100, 100), rand.Next(-100, 100), rand.Next(-100, 100)), new Vector3(1, 1, 1), rand.Next(1, 9)); objs.Add(m_Spheroid); } Console.SetCursorPosition(0, Console.CursorTop); Console.Write(">"); ControlPlane control = new ControlPlane(objs, THREADS); control.Start(); }
void Start() { image = GetComponent <Image>(); knobImage = transform.GetChild(0).gameObject.GetComponent <Image>(); ControlPlane control = ControlPlane.Get(); input = control.DigitalInputs[InputIndex]; if (LedIndex >= 0) { led = control.Leds[LedIndex]; } else { knobImage.color = LedOffColor; } }
public double Get_max_k_stall_htail() { double ret = 0.0D; int i; for (i = 0; i < n_htail; i++) { Wing wg = htail[i]; for (int lr = 0; lr < wg.n_lr; lr++) { for (int j = 0; j < wg.n_wing_block; j++) { WingPlane wp = wg.wp[j, lr]; if (wp.k_stall <= ret) { continue; } ret = wp.k_stall; } } } for (i = 0; i < n_elevator; i++) { for (int lr_0 = 0; lr_0 <= 1; lr_0++) { ControlPlane cp = elevator[i, lr_0]; if (cp.type != 0) { WingPlane wp_1 = cp.baseWingBlock; if (wp_1.k_stall <= ret) { continue; } ret = wp_1.k_stall; } } } return(ret); }
// Constructor Function public SizeAvatar(Mesh sized, Mesh templateLen, HumanBody template) { testList = new ArrayList(); templateBody = template; sizedMesh = sized; templateMesh = template.getMesh(); templateBone = template.getBones(); mRoot = template.getTransform(); templateLenMesh = templateLen; measurement = new Dictionary <HumanSize, float> (); initMeasurements = new float[(int)HumanSize.Undefined]; planes = new ControlPlane(); mLocalPosInBone0 = new Vector3[templateMesh.vertexCount]; mLocalPosInBone1 = new Vector3[templateMesh.vertexCount]; mLocalPosInBone2 = new Vector3[templateMesh.vertexCount]; mLocalPosInBone3 = new Vector3[templateMesh.vertexCount]; templateShoulderLPos = templateBody.boneInfo [HumanBone.L_Clavicle].localPosition; templateShoulderRPos = templateBody.boneInfo [HumanBone.R_Clavicle].localPosition; updateLocalPosInBones(); initMearsurement(); }
private void ReadControlPlaneFlapType(ControlPlane cpR, ControlPlane cpL, bool flagMessage) { String flap_type_name = ReadString("flap", flagMessage); cpR.flap_type = 0; cpL.flap_type = 0; for (int i = 0; i < Flap.flap_type_name.Length; i++) { if (Flap.flap_type_name[i].Equals(flap_type_name)) { cpR.flap_type = i; } } cpR.cf_c = ReadDblValue("cf/c", flagMessage); cpR.dCLmax = ReadDblValue("dCLmax", flagMessage); if (cpR.type != 0) { cpL.flap_type = cpR.flap_type; cpL.cf_c = cpR.cf_c; cpL.dCLmax = cpR.dCLmax; } }
private void ReadControlPlane(Wing wg, ControlPlane cpR, ControlPlane cpL, bool flagMessage) { cpR.type = 0; cpL.type = 0; String typeStr = ReadString("type", flagMessage); if (typeStr.Equals("all_flying")) { cpR.type = 2; } else if (typeStr.Equals("tailing_edge")) { cpR.type = 1; } else if (typeStr.Equals("leading_edge")) { cpR.type = 1; } else { cpR.type = 0; } typeStr = ReadString("actuate_type", flagMessage); if (typeStr.Equals("actuator_drive")) { cpR.actuate_type = 1; } else { cpR.actuate_type = 0; } if (wg.n_lr == 2) { cpL.type = cpR.type; cpL.actuate_type = cpR.actuate_type; } ReadWingPlane(wg, cpR.baseWingBlock, cpL.baseWingBlock, flagMessage); cpR.delta_max = MathTool.DegToRad(ReadDblValue("delta_max", flagMessage)); cpR.delta_min = MathTool.DegToRad(ReadDblValue("delta_min", flagMessage)); cpR.lamda_h = MathTool.DegToRad(ReadDblValue("lamda_H", flagMessage)); if (cpL.type != 0) { cpL.delta_max = cpR.delta_max; cpL.delta_min = cpR.delta_min; cpL.lamda_h = cpR.lamda_h; } if ((cpR.type == 1) || (cpR.type == 1)) { ReadControlPlaneFlapType(cpR, cpL, flagMessage); } if (cpR.type == 2) { ReadControlPlaneAllFType(cpR, cpL, flagMessage); } if (cpR.actuate_type == 1) { cpR.t_move = ReadDblValue("t_moving", flagMessage); if ((cpL.baseWingBlock != null) && (cpL.baseWingBlock.flag == 1)) { cpL.t_move = cpR.t_move; } } cpR.Init(); cpL.Init(); }
void Start() { led = ControlPlane.Get().Leds[Index]; image = GetComponent <Image>(); }
private void button1_Click(object sender, EventArgs e) { if (MyModel.GetConnectionStatus()) { double off1 = Convert.ToDouble(textBox4.Text); double off2 = Convert.ToDouble(textBox5.Text); TransformationPlane currentPlane = MyModel.GetWorkPlaneHandler().GetCurrentTransformationPlane(); Picker piku = new Picker(); ArrayList info = new ArrayList(); info = new ArrayList { "END_X", "END_Y", "END_Z", "START_X", "START_Y", "START_Z" }; ArrayList info2 = new ArrayList(); info2 = new ArrayList { "END_X", "END_Y", "END_Z", "START_X", "START_Y", "START_Z" }; ModelObject part = new Beam(); ModelObject part2 = new Beam(); Hashtable p1 = new Hashtable(); Hashtable p2 = new Hashtable(); part = piku.PickObject(Picker.PickObjectEnum.PICK_ONE_PART); part.GetDoubleReportProperties(info, ref p1); double rotpart = (part as Part).Position.RotationOffset; part2 = piku.PickObject(Picker.PickObjectEnum.PICK_ONE_PART); part2.GetDoubleReportProperties(info2, ref p2); double rotpart2 = (part2 as Part).Position.RotationOffset; Point st1 = new Point(Convert.ToDouble(p1["START_X"]), Convert.ToDouble(p1["START_Y"]), Convert.ToDouble(p1["START_Z"])); Point st2 = new Point(Convert.ToDouble(p2["END_X"]), Convert.ToDouble(p2["END_Y"]), Convert.ToDouble(p2["END_Z"])); Point st3 = new Point(Convert.ToDouble(p1["END_X"]), Convert.ToDouble(p1["END_Y"]), Convert.ToDouble(p1["END_Z"])); Point st4 = new Point(Convert.ToDouble(p2["START_X"]), Convert.ToDouble(p2["START_Y"]), Convert.ToDouble(p2["START_Z"])); LineSegment l1 = new LineSegment(st1, st2); LineSegment l3 = new LineSegment(st1, st3); Vector vl3 = l3.GetDirectionVector(); vl3.Normalize(); LineSegment l4 = new LineSegment(st2, st1); LineSegment l5 = new LineSegment(st2, st4); Vector vl5 = l5.GetDirectionVector(); vl5.Normalize(); st1.Translate(vl3.X * (off1 / vl3.GetLength()), vl3.Y * (off1 / vl3.GetLength()), vl3.Z * (off1 / vl3.GetLength())); st2.Translate(vl5.X * (off2 / vl5.GetLength()), vl5.Y * (off2 / vl5.GetLength()), vl5.Z * (off2 / vl5.GetLength())); ControlLine cl1 = new ControlLine(l1, true); cl1.Color = ControlLine.ControlLineColorEnum.YELLOW_RED; //cl1.Insert(); CoordinateSystem cs1 = new CoordinateSystem(); cs1 = part.GetCoordinateSystem(); CoordinateSystem cs2 = new CoordinateSystem(); cs2 = part2.GetCoordinateSystem(); Tekla.Structures.Model.Plane pl1 = new Tekla.Structures.Model.Plane(); pl1.AxisX = cs1.AxisX; pl1.AxisY = cs1.AxisY; pl1.Origin = cs1.Origin; Tekla.Structures.Model.Plane pl2 = new Tekla.Structures.Model.Plane(); pl2.AxisX = cs2.AxisX; pl2.AxisY = cs2.AxisY; pl2.Origin = cs2.Origin; GeometricPlane gp1 = new GeometricPlane(cs1); GeometricPlane gp2 = new GeometricPlane(cs2); ControlPlane cp1 = new ControlPlane(pl1, true); //cp1.Insert(); ControlPlane cp2 = new ControlPlane(pl2, true); //cp2.Insert(); LineSegment l2 = Projection.LineSegmentToPlane(l1, gp1); LineSegment l6 = Projection.LineSegmentToPlane(l4, gp2); ControlLine cl2 = new ControlLine(l2, true); ControlLine cl3 = new ControlLine(l6, true); cl2.Color = ControlLine.ControlLineColorEnum.YELLOW_RED; //cl2.Insert(); cl3.Color = ControlLine.ControlLineColorEnum.YELLOW_RED; //cl3.Insert(); Part p3 = part as Part; Solid sl1 = p3.GetSolid(); ArrayList al1 = sl1.Intersect(l2); Point px = new Point(al1[1] as Point); ControlPoint cpp1 = new ControlPoint(px); //cpp1.Insert(); Part p4 = part2 as Part; Solid sl2 = p4.GetSolid(); ArrayList al2 = sl2.Intersect(l6); Point py = new Point(al2[1] as Point); ControlPoint cpp4 = new ControlPoint(py); //cpp4.Insert(); double distance = Distance.PointToLineSegment(st3, l2); double distance1 = l3.Length(); double cos = distance / distance1; double distance2 = Distance.PointToLineSegment(st4, l6); double distance3 = l5.Length(); double cos1 = distance2 / distance3; Point p10 = dlugosc(st1, st3, 4, cos, px); ControlPoint cpp2 = new ControlPoint(p10); //cpp2.Insert(); Point p20 = dlugosc(st2, st4, 4, cos1, py); ControlPoint cpp5 = new ControlPoint(p20); //cpp5.Insert(); Point p5 = new Point(l2.StartPoint); Point p6 = new Point(l2.EndPoint); Vector v1 = new Vector((p6.X - p5.X) / 10000, (p6.Y - p5.Y) / 10000, (p6.Z - p5.Z) / 10000); double v1d = v1.GetLength(); double dlbl = Convert.ToDouble(textBox2.Text); Point p11 = new Point(px); p11.Translate(v1.X * (dlbl / v1d), v1.Y * (dlbl / v1d), v1.Z * (dlbl / v1d)); Point p12 = dlugosc(st1, st3, 4, cos, p11); ControlPoint cpp3 = new ControlPoint(p12); //cpp3.Insert(); Point p7 = new Point(l6.StartPoint); Point p8 = new Point(l6.EndPoint); Vector v2 = new Vector((p8.X - p7.X) / 10000, (p8.Y - p7.Y) / 10000, (p8.Z - p7.Z) / 10000); double v2d = v2.GetLength(); double dlbl1 = Convert.ToDouble(textBox2.Text); Point p21 = new Point(py); p21.Translate(v2.X * (dlbl1 / v2d), v2.Y * (dlbl1 / v2d), v2.Z * (dlbl1 / v2d)); Point p22 = dlugosc(st2, st4, 4, cos1, p21); ControlPoint cpp6 = new ControlPoint(p22); //cpp6.Insert(); Beam blachast = CreateBlacha(p10, p12, rotpart, 0, textBox1.Text); blachast.Insert(); int id1 = blachast.Identifier.ID; Identifier id11 = new Identifier(id1); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st1, vl3, v1)); ModelObject blachast3 = MyModel.SelectModelObject(id11); double rotblachast = (blachast3 as Beam).Position.RotationOffset; MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); //textBox1.Text = Convert.ToString(rotblachast); blachast.Position.RotationOffset = -rotblachast; blachast.PartNumber.Prefix = "PL"; blachast.PartNumber.StartNumber = 1001; blachast.Modify(); Beam blachast2 = CreateBlacha(p20, p22, rotpart2, 1, textBox1.Text); blachast2.Insert(); int id2 = blachast2.Identifier.ID; Identifier id12 = new Identifier(id2); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st2, vl5, v2)); ModelObject blachast4 = MyModel.SelectModelObject(id12); double rotblachast2 = (blachast4 as Beam).Position.RotationOffset; MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); blachast2.Position.RotationOffset = -rotblachast2; blachast2.PartNumber.Prefix = "PL"; blachast2.PartNumber.StartNumber = 1001; blachast2.Modify(); Point p15 = new Point(p12); p15.Translate(v1.X * (-30 / v1d), v1.Y * (-30 / v1d), v1.Z * (-30 / v1d)); ControlPoint cpp7 = new ControlPoint(p15); //cpp7.Insert(); Point p16 = new Point(p22); p16.Translate(v2.X * (-30 / v2d), v2.Y * (-30 / v2d), v2.Z * (-30 / v2d)); ControlPoint cpp8 = new ControlPoint(p16); //cpp8.Insert(); Vector v11516 = new Vector((p16.X - p15.X) / 10000, (p16.Y - p15.Y) / 10000, (p16.Z - p15.Z) / 10000); Point p151 = new Point(p15); Point p152 = new Point(p15); Point p153 = new Point(p15); Point p161 = new Point(p16); Point p162 = new Point(p16); Point p163 = new Point(p16); p151.Translate(v11516.X * (-30 / v11516.GetLength()), v11516.Y * (-30 / v11516.GetLength()), v11516.Z * (-30 / v11516.GetLength())); p152.Translate(v11516.X * (120 / v11516.GetLength()), v11516.Y * (120 / v11516.GetLength()), v11516.Z * (120 / v11516.GetLength())); p153.Translate(v11516.X * (70 / v11516.GetLength()), v11516.Y * (70 / v11516.GetLength()), v11516.Z * (70 / v11516.GetLength())); p161.Translate(v11516.X * (30 / v11516.GetLength()), v11516.Y * (30 / v11516.GetLength()), v11516.Z * (30 / v11516.GetLength())); p162.Translate(v11516.X * (-120 / v11516.GetLength()), v11516.Y * (-120 / v11516.GetLength()), v11516.Z * (-120 / v11516.GetLength())); p163.Translate(v11516.X * (-70 / v11516.GetLength()), v11516.Y * (-70 / v11516.GetLength()), v11516.Z * (-70 / v11516.GetLength())); Beam BlSt1 = BlachaSt(p151, p152, 0); BlSt1.Insert(); int id3 = BlSt1.Identifier.ID; Identifier id13 = new Identifier(id3); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st1, vl3, v1)); ModelObject blachast5 = MyModel.SelectModelObject(id13); double rot5 = (blachast5 as Beam).Position.RotationOffset; MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); //textBox1.Text = Convert.ToString(rotblachast); BlSt1.Position.RotationOffset = -rot5; BlSt1.PartNumber.Prefix = "PL"; BlSt1.PartNumber.StartNumber = 1001; BlSt1.Modify(); Beam BlSt2 = BlachaSt(p161, p162, 1); BlSt2.Insert(); int id4 = BlSt2.Identifier.ID; Identifier id14 = new Identifier(id4); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st2, vl5, v2)); ModelObject blachast6 = MyModel.SelectModelObject(id14); double rot6 = (blachast6 as Beam).Position.RotationOffset; MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); //textBox1.Text = Convert.ToString(rotblachast); BlSt2.Position.RotationOffset = -rot6; BlSt2.PartNumber.Prefix = "PL"; BlSt2.PartNumber.StartNumber = 1001; BlSt2.Modify(); Beam St12 = CreateStezenie12(p153, p163); St12.Insert(); int id5 = St12.Identifier.ID; Identifier id15 = new Identifier(id5); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st1, vl3, v1)); ModelObject stezenie1 = MyModel.SelectModelObject(id15); (stezenie1 as Beam).StartPointOffset.Dy = 4; (stezenie1 as Part).PartNumber.Prefix = "Pr"; (stezenie1 as Part).PartNumber.StartNumber = 1001; stezenie1.Modify(); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st2, vl5, v2)); ModelObject stezenie2 = MyModel.SelectModelObject(id15); (stezenie2 as Beam).EndPointOffset.Dy = -6; (stezenie2 as Part).PartNumber.Prefix = "Pr"; (stezenie2 as Part).PartNumber.StartNumber = 1001; stezenie2.Modify(); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); double split = Convert.ToDouble(textBox3.Text); Point pointsplit = new Point(p163); pointsplit.Translate(v11516.X * (-split / v11516.GetLength()), v11516.Y * (-split / v11516.GetLength()), v11516.Z * (-split / v11516.GetLength())); BoltArray b1 = sruby(p151, p152, BlSt1, blachast); b1.Insert(); int id6 = b1.Identifier.ID; Identifier id16 = new Identifier(id6); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st1, vl3, v1)); ModelObject b1m = MyModel.SelectModelObject(id16); (b1m as BoltArray).Position.RotationOffset = 0; (b1m as BoltArray).BoltStandard = "4017-8.8"; (b1m as BoltArray).ExtraLength = 5; b1m.Modify(); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); BoltArray b2 = sruby(p161, p162, BlSt2, blachast2); b2.Insert(); int id7 = b2.Identifier.ID; Identifier id17 = new Identifier(id7); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(setWorkPlane(st2, vl5, v2)); ModelObject b2m = MyModel.SelectModelObject(id17); (b2m as BoltArray).Position.RotationOffset = 180; b2m.Modify(); MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); Weld w = new Weld(); Weld w2 = new Weld(); Weld w3 = new Weld(); Weld w4 = new Weld(); w.MainObject = stezenie2; w.SecondaryObject = BlSt1; w.ShopWeld = true; w.Insert(); w2.MainObject = stezenie2; w2.SecondaryObject = BlSt2; w2.ShopWeld = true; w2.Insert(); w3.MainObject = part; w3.SecondaryObject = blachast; w3.ShopWeld = true; w3.Insert(); w4.MainObject = part2; w4.SecondaryObject = blachast2; w4.ShopWeld = true; w4.Insert(); Beam st122 = Operation.Split(stezenie2 as Beam, pointsplit); Connection sr = new Connection(); sr.Name = "Połączenie śrubą rzymską"; sr.Number = 126; sr.LoadAttributesFromFile("82269_M12"); sr.SetPrimaryObject(stezenie2); sr.SetSecondaryObject(st122); sr.Insert(); } MyModel.CommitChanges(); }
public void ControlLink(double dt) { int i; for (i = 0; i < n_elevator; i++) { if (elevator[i, 0].type != 0) { ControlPlane ele = elevator[i, 0]; ele.delta = ((1.0D - cif.stick_pos_y) / 2.0D * (ele.delta_max - ele.delta_min) + ele.delta_min); } if (elevator[i, 1].type != 0) { elevator[i, 1].delta = elevator[i, 0].delta; } } for (i = 0; i < n_canard_elevator; i++) { if (canard_elevator[i, 0].type != 0) { if (cif.stick_pos_y > 0.0D) { canard_elevator[i, 0].delta = (cif.stick_pos_y * canard_elevator[i, 0].delta_min); } else { canard_elevator[i, 0].delta = (-cif.stick_pos_y * canard_elevator[i, 0].delta_max); } } if (canard_elevator[i, 1].type != 0) { canard_elevator[i, 1].delta = canard_elevator[i, 0].delta; } } for (i = 0; i < n_aileron; i++) { if (aileron[i, 0].type != 0) { if (cif.stick_pos_x >= 0.0D) { aileron[i, 0].delta = (cif.stick_pos_x * aileron[i, 0].delta_min); } else { aileron[i, 0].delta = (-cif.stick_pos_x * aileron[i, 0].delta_max); } } if (aileron[i, 1].type != 0) { if (cif.stick_pos_x >= 0.0D) { aileron[i, 1].delta = (cif.stick_pos_x * aileron[i, 1].delta_max); } else { aileron[i, 1].delta = (-cif.stick_pos_x * aileron[i, 1].delta_min); } } } for (i = 0; i < n_rudder; i++) { if (rudder[i, 0].type != 0) { if (cif.rudder_pos > 0.0D) { rudder[i, 0].delta = (-cif.frudder_pos.output * rudder[i, 0].delta_min); } else { rudder[i, 0].delta = (cif.frudder_pos.output * rudder[i, 0].delta_max); } } if (rudder[i, 1].type != 0) { rudder[i, 1].delta = rudder[i, 1].delta; } } for (i = 0; i < n_LandingGear; i++) { if (landing_gear[i, 0].flag != 0) { landing_gear[i, 0].brake = cif.brakeRight_pos; } if (landing_gear[i, 1].flag != 0) { landing_gear[i, 1].brake = cif.brakeLeft_pos; } } for (i = 0; i < n_t_flap; i++) { t_flap[i, 0].Update(cif.flap_sw, dt); t_flap[i, 1].delta = t_flap[i, 0].delta; } for (i = 0; i < n_powerPlant; i++) { powerPlant[i].throttle = (1.0D - System.Math.Cos(cif.throttle_pos * Math.PI * 0.5D)); } }
public double Get_max_k_stall_wing() { double ret = 0.0D; int i; for (i = 0; i < n_wing; i++) { Wing wg = wing[i]; for (int lr = 0; lr < wg.n_lr; lr++) { for (int j = 0; j < wg.n_wing_block; j++) { WingPlane wp = wg.wp[j, lr]; if (wp.k_stall <= ret) { continue; } ret = wp.k_stall; } } } for (i = 0; i < n_aileron; i++) { for (int lr_0 = 0; lr_0 <= 1; lr_0++) { ControlPlane cp = aileron[i, lr_0]; if (cp.type != 0) { WingPlane wp_1 = cp.baseWingBlock; if (wp_1.k_stall <= ret) { continue; } ret = wp_1.k_stall; } } } for (i = 0; i < n_t_flap; i++) { for (int lr_2 = 0; lr_2 <= 1; lr_2++) { ControlPlane cp_3 = t_flap[i, lr_2]; if (cp_3.type != 0) { WingPlane wp_4 = cp_3.baseWingBlock; if (wp_4.k_stall <= ret) { continue; } ret = wp_4.k_stall; } } } for (i = 0; i < n_l_flap; i++) { for (int lr_5 = 0; lr_5 <= 1; lr_5++) { ControlPlane cp_6 = l_flap[i, lr_5]; if (cp_6.type != 0) { WingPlane wp_7 = cp_6.baseWingBlock; if (wp_7.k_stall <= ret) { continue; } ret = wp_7.k_stall; } } } return(ret); }
public void MakeObject() { int i; for (i = 0; i < 7; i++) { for (int lr = 0; lr <= 1; lr++) { fuslage[i, lr] = new Fuselage(); } } for (i = 0; i < 1; i++) { wing[i] = new Wing(); } for (i = 0; i < 1; i++) { htail[i] = new Wing(); } for (i = 0; i < 1; i++) { vtail[i] = new Wing(); } for (i = 0; i < 1; i++) { canard[i] = new Wing(); } for (i = 0; i < 5; i++) { fin[i] = new Wing(); } for (i = 0; i < 1; i++) { for (int lr_0 = 0; lr_0 <= 1; lr_0++) { elevator[i, lr_0] = new ControlPlane(); } } for (i = 0; i < 1; i++) { for (int lr_1 = 0; lr_1 <= 1; lr_1++) { aileron[i, lr_1] = new ControlPlane(); } } for (i = 0; i < 1; i++) { for (int lr_2 = 0; lr_2 <= 1; lr_2++) { rudder[i, lr_2] = new ControlPlane(); } } for (i = 0; i < 1; i++) { for (int lr_3 = 0; lr_3 <= 1; lr_3++) { t_flap[i, lr_3] = new ControlPlane(); } } for (i = 0; i < 1; i++) { for (int lr_4 = 0; lr_4 <= 1; lr_4++) { l_flap[i, lr_4] = new ControlPlane(); } } for (i = 0; i < 1; i++) { for (int lr_5 = 0; lr_5 <= 1; lr_5++) { canard_elevator[i, lr_5] = new ControlPlane(); } } for (i = 0; i < 3; i++) { for (int lr_6 = 0; lr_6 <= 1; lr_6++) { landing_gear[i, lr_6] = new LandingGear(); } } }
public Led(ControlPlane control, byte index) { this.control = control; this.Index = index; }
public void DrawInstrument(Graphics g, AirPlane ap, SimulatorInterface simif, double dt) { Matrix44 tmat = new Matrix44(); Matrix44 smat = new Matrix44(); Matrix44 rmat = new Matrix44(); Matrix44 rzmat = new Matrix44(); Matrix44 rxmat = new Matrix44(); Matrix44 mat = new Matrix44(); Scine scine = new Scine(); //g.SetColor(informationColor); //g.SetFont(stdFont); SolidBrush informationBrush = new SolidBrush(informationColor); Pen informationPen = new Pen(informationColor); g.DrawString(ap.plane.name, stdFont, informationBrush, 300 - ap.plane.name.Length * 3, 365); if (simif.dispInformationSw == 1) { double x = ap.pMotion.ov.Length(); //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x, 3, 1) + " m/s", v_true_x, v_true_y); //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kmph(x), 3, 1) + " km/h", v_true_x, v_true_y + 12); //g.DrawString("V: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kt(x), 3, 1) + " kt", v_true_x, v_true_y + 24); x = ap.pMotion.wpos.y; //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x, 5, 1) + " m", alt_x, alt_y); //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x), 5, 1) + " ft", alt_x, alt_y + 12); } double pitch = ap.pMotion.pitch.GetValue(); double roll = ap.pMotion.roll.GetValue(); g.DrawString("PIT: " + DispFormat.DoubleFormat(MathTool.RadToDeg(pitch), 5, 1) + " deg", stdFont, informationBrush, 515, 12); g.DrawString("ROL: " + DispFormat.DoubleFormat(MathTool.RadToDeg(roll), 5, 1) + " deg", stdFont, informationBrush, 512, 89); tmat.SetTMat(550.0D, 45.0D, 0.0D); smat.SetSMat(30.0D, -30.0D, 0.0D); if ((roll > 1.570796326794897D) || (roll < -1.570796326794897D)) { rmat.SetRzMat(Math.PI - pitch); } else { rmat.SetRzMat(pitch); } mat = smat.MultMat(rmat).MultMat(tmat); scine.Add(pitch_miniature_aircraft.Transform(mat)); g.DrawEllipse(informationPen, 520, 15, 60, 60); tmat.SetTMat(550.0D, 121.0D, 0.0D); smat.SetSMat(30.0D, -30.0D, 0.0D); rmat.SetRzMat(-roll); mat = smat.MultMat(rmat).MultMat(tmat); scine.Add(roll_miniature_aircraft.Transform(mat)); g.DrawEllipse(informationPen, 520, 91, 60, 60); if (simif.dispInformationSw == 1) { double x_0 = ap.atmos.h; //g.DrawString("H': " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 5, 1) + " m'", atmo_x, atmo_y); x_0 = ap.atmos.tc; //g.DrawString("t: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 4, 1) + " ��", atmo_x, atmo_y + 12); x_0 = ap.atmos.t; //g.DrawString("T: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 4, 1) + " K", atmo_x, atmo_y + 24); x_0 = ap.atmos.p; //g.DrawString("p: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0 / 100.0D, 4, 1) + " hPa", atmo_x + 90, atmo_y); x_0 = ap.atmos.rho; //g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 1, 3) + " kg/m3", atmo_x + 90, atmo_y + 12); x_0 = ap.atmos.a; // g.DrawString("a: " + Jp.Maker1.Util.DispFormat.DoubleFormat(x_0, 3, 1) + " m/sec", atmo_x + 90, atmo_y + 24); } double alpha = ap.pMotion.alpha; double beta = ap.pMotion.beta; if (simif.dispInformationSw == 1) { //g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(alpha), 3, 1) + " deg", 2, 60); // g.DrawString("��: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(beta), 3, 1) + " deg", 2, 72); } Vector3D vec = ap.pMotion.ov.SclProd(60000000.0D).MultMat(ap.pilot.ViewMatrix()); if ((vec != null) && (vec.z > 0.0D)) { vec = proj.Project(vec); tmat.SetTMat(vec.x, vec.y, vec.z); scine.Add(velocity_vector.Transform(tmat)); } vec.SetVec(0.0D, 0.0D, 60000000.0D); vec = vec.MultMat(ap.pilot.ViewMatrix()); if ((vec != null) && (vec.z > 0.0D)) { vec = proj.Project(vec); tmat.SetTMat(vec.x, vec.y, vec.z); scine.Add(front_point.Transform(tmat)); } vec = ap.pMotion.force.R2l().SclProd(-1.0D / ap.inp.m); vec.z = 0.0D; double x_1 = vec.Length(); Vector3D vec2 = vec.NmlVec().SclProd(50.0D); vec = vec.NmlVec().SclProd(100.0D); Vector3D vec3 = vec.NmlVec().SclProd(113.0D); Jp.Maker1.Util.Symbol.DrawArrow(g, 300 + (int)vec2.x, 200 - (int)vec2.y, 300 + (int)vec.x, 200 - (int)vec.y, 50.0D, x_1 * 4.0D); //g.DrawString(Jp.Maker1.Util.DispFormat.DoubleFormat(x_1 / 9.80655D, 2) + "G", 286 + (int)vec3.x, 200 - (int)vec3.y); vec = ap.pMotion.force.R2l().SclProd(-1.0D / ap.inp.m); x_1 = vec.z; // g.DrawString(Jp.Maker1.Util.DispFormat.DoubleFormat(x_1 / 9.80655D, 2) + "G", 120, 192); if (Math.Abs((int)(x_1 * 10.0D)) >= 1) { Jp.Maker1.Util.Symbol.DrawArrow(g, 150, 200, 150 + (int)(x_1 * 10.0D), 200, (int)(Math.Abs(x_1) * 10.0D), 10.0D); Jp.Maker1.Util.Symbol.DrawArrow(g, 450, 200, 450 - (int)(x_1 * 10.0D), 200, (int)(Math.Abs(x_1) * 10.0D), 10.0D); } int xx = 2; int yy = 100; vec = ap.pMotion.force.SclProd(-1.0D / ap.inp.m / 9.80655D); if (simif.dispInformationSw == 1) { //g.DrawString("Gx: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.x, 2, 4) + " [G]", xx, yy); yy += 11; // g.DrawString("Gy: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.y, 2, 4) + " [G]", xx, yy); yy += 11; //g.DrawString("Gz: " + Jp.Maker1.Util.DispFormat.DoubleFormat(vec.z, 2, 4) + " [G]", xx, yy); yy += 11; } if (ap.max_k_stall_wing > 1.0D) { //g.DrawString("STALL", stallAlert_x + 25, stallAlert_y); } else if (ap.max_k_stall_wing > 0.95D) { //g.DrawString("STALL WARNING", stallAlert_x, stallAlert_y); } //g.SetColor(instrumentColor); double yaw = ap.pMotion.yaw.GetValue(); //g.DrawString("HDG: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(yaw), 5, 1) + " deg", 512, 165); tmat.SetTMat(550.0D, 197.0D, 0.0D); smat.SetSMat(30.0D, 30.0D, 0.0D); rmat.SetRzMat(yaw); mat = smat.MultMat(rmat).MultMat(tmat); scine.Add(heading_miniature_aircraft.Transform(mat)); // g.DrawOval(520, 167, 60, 60); rzmat.SetRzMat(-ap.pMotion.roll.GetValue()); rxmat.SetRxMat(-ap.pMotion.pitch.GetValue()); mat = rxmat.MultMat(rzmat); Scine scine2 = new Scine(); scine2.Add(artificial_horizon.Transform(mat.MultMat(ap.pilot.ViewMatrix()))); Scine view = new Scine(); view = scine2.MakeView(clip, proj, false); view.Draw(g); // g.SetFont(bigFont); x_1 = ap.pMotion.vc.Length() * Math.Sqrt(ap.atmos.rho / 1.225D); // g.DrawString("ASI: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.Mps2kt(x_1), 3, 0) + " kt", 190, 380); x_1 = ap.pMotion.wpos.y; //g.DrawString("ALT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x_1), 5, 0) + " ft", 190, 396); x_1 = ap.pMotion.wv.y; //g.DrawString("VSI: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Sim.Tools.UnitConvert.M2ft(x_1) * 60.0D, 5, 0) + " fpm", 305, 380); x_1 = ap.pMotion.omega.z; // g.DrawString("YRT: " + Jp.Maker1.Util.DispFormat.DoubleFormat(Jp.Maker1.Util.MathTool.RadToDeg(x_1) * 60.0D, 3, 0) + " deg/m", 305, 396); for (int i = 0; i < ap.n_LandingGear; i++) { if (ap.landing_gear[i, 1].flag == 1) { xx = gear_x; } else { xx = gear_x - gear_box_maegine / 2; } yy = gear_y + i * gear_box_maegine * 3; for (int lr = 0; lr <= 1; lr++) { if (ap.landing_gear[i, lr].flag == 1) { int xx1; if (lr == 0) { xx1 = xx + gear_box_maegine; } else { xx1 = xx; } x_1 = ap.landing_gear[i, lr].delta; if (x_1 == 0.0D) { //g.SetColor(instrumentRed); //g.FillRect(xx1 + 2, yy + 2, gear_box_size - 3, gear_box_size - 3); } else if (x_1 == 1.0D) { //g.SetColor(instrumentGreen); //g.FillRect(xx1 + 2, yy + 2 + gear_box_maegine * 2, gear_box_size - 3, gear_box_size - 3); } else { // g.SetColor(instrumentYellow); // g.FillRect(xx1 + 2, yy + 2 + gear_box_maegine, gear_box_size - 3, gear_box_size - 3); } //g.SetColor(instrumentColor); //g.DrawRect(xx1, yy, gear_box_size, gear_box_size); //g.DrawRect(xx1, yy + gear_box_maegine, gear_box_size, gear_box_size); //g.DrawRect(xx1, yy + gear_box_maegine * 2, gear_box_size, gear_box_size); } } } //g.SetFont(smallFont); ControlPlane flap = ap.t_flap[0, 0]; if (ap.t_flap[0, 0].type != 0) { xx = flap_x; yy = flap_y; // g.DrawRect(xx, yy - flap_width, 10, flap_width); for (double ang = 0.0D; ang < MathTool.RadToDeg(flap.delta_max) + 0.1D; ang += 10.0D) { x_1 = (MathTool.DegToRad(ang) - flap.delta_min) / (flap.delta_max - flap.delta_min); int yy1 = yy - flap_width + (int)(flap_width * x_1 + 0.5D); // g.DrawLine(xx + 10, yy1, xx + 13, yy1); // g.DrawString("" + (int)ang, xx + 14, yy1); } x_1 = (flap.delta - flap.delta_min) / (flap.delta_max - flap.delta_min); int yy1_2 = (int)(flap_width * x_1 + 0.5D); // g.FillRect(xx + 2, yy - flap_width, 7, yy1_2); } //g.SetFont(stdFont); scine.Draw(g); //g.SetFont(stdFont); }
internal void Calc_dynamics(int lr, ControlPlane cw, AirPlane ap, Vector3D dv, double k_q, double k_S) { Matrix44 ma = new Matrix44(); Matrix44 mtemp = new Matrix44(); Vector3D vtemp = new Vector3D(); fv.SetVec(0.0D, 0.0D, 0.0D); tv.SetVec(0.0D, 0.0D, 0.0D); ac = AirPlane.Get_point(ac_base, lr).Sub(ap.inp.cg); dvv = ap.pMotion.omega.CrsProd(ac); vd = ap.pMotion.vc.Add(dvv); vd = vd.Add(dv); v = vd.Length(); vd = vd.NmlVec().SclProd(v * k_q); v = vd.Length(); s2_dash = (s2 * k_S); m = (v / ap.atmos.a); q = (0.5D * v * v * ap.atmos.rho); Vector3D kdd = new Vector3D(); Vector3D idd = new Vector3D(); Vector3D jdd = new Vector3D(); if ((cw != null) && (cw.type == 2)) { ma.SetRyMat(cw.delta); mtemp.SetRzMat(cw.lamda_h); ma = ma.MultMat(mtemp); if (lr == 1) { mtemp.SetRxMat(-cw.gamma_h); } else { mtemp.SetRxMat(-cw.gamma_h); } ma = ma.MultMat(mtemp); idd = id.MultMat(ma); kdd = kd.MultMat(ma); } else { idd = new Vector3D(id); jdd = new Vector3D(jd); kdd = new Vector3D(kd); } mtemp.Set3ColVec(idd, jdd, kdd); vdw = vd.MultMat(mtemp); alpha = Jp.Maker1.Sim.Tools.Tool.CalcAlpha(vdw); beta = Jp.Maker1.Sim.Tools.Tool.CalcBeta(vdw); ar = wing.AspectRatio(beta); are = (ar * wing.K_ground_effect(beta, ap.pMotion.wpos.y)); lamda_dash = SweepbackAngle(wing.hv_arrangement, lr, beta); Calc_cla(); delta_cl_flap = 0.0D; delta_cd_flap = 0.0D; delta_cmac_flap = 0.0D; delta_alpha = 0.0D; k_a = 1.0D; if ((cw != null) && ((cw.type == 1) || (cw.type == 1))) { cw.beta_f = Flap.Beta_f(lr, wing.hv_arrangement, cw.lamda_h, beta); cw.delta_dash = Flap.Delta_dash(cw.delta, cw.beta_f); if (Math.Abs(cw.beta_f) < 1.570796326794897D) { delta_alpha = (cw.f_lamda1 * cw.delta_dash); delta_cmac_flap = cw.f_cmac; } else { delta_alpha = (cw.b_lamda1 * cw.delta_dash); delta_cmac_flap = cw.b_cmac; } k_a = Flap.K_cla(cw.delta_dash, cw.cf_c); delta_cl_flap = (k_a * cla * delta_alpha); delta_cmac_flap *= (alpha + delta_alpha - alpha0); } vtemp.SetVec(0.0D, 0.0D, -1.0D); ma.SetRyMat(-alpha); mtemp.SetRzMat(beta); ma = ma.MultMat(mtemp); mtemp.Set3RowVec(idd, jdd, kdd); ma = ma.MultMat(mtemp); lu = vtemp.MultMat(ma); du = vd.SclProd(-1.0D).NmlVec(); alpha += delta_alpha; cla *= k_a; Calc_cl_cd(); l = (q * cl * s2_dash); cdi = (cl * cl / (Math.PI * are * ew)); cd += cdi; cd += delta_cd_flap; d = (q * cd * s2_dash); lf = Dynamics.Force(l, lu); lt = Dynamics.Torque(ac, lf); df = Dynamics.Force(d, du); dt = Dynamics.Torque(ac, df); cmac = cmac0; cmac += delta_cmac_flap; mac = (q * s2_dash * cmac); Vector3D mt_0 = new Vector3D(0.0D, mac, 0.0D); fv = lf.Add(df); tv = lt.Add(dt).Add(mt_0); }