public frm_Main() { InitializeComponent(); //button21.Visible = false; //button41.Visible = false; hinhTru = new HinhTru(10, -10, 0, 30, 10); hinhTruProperties = new HinhTruProperties(); hinhTruProperties.Visible = false; hinhHopChuNhat = new HinhHopChuNhat(0, 0, 0, 10, 10, 10); hinhHopChuNhatProperties = new HinhHopChuNhatProperties(); hinhHopChuNhatProperties.Visible = false; // Tạo quả lắc theo kích thước cho trước pendulum = new Pendulum(new Point(100, 20), new Point(400, 220)); pendulum.SetAlpha(-3); // set góc quay alpha pendulum.PropertyChanged += Pendulum_PropertyChanged; //2D mode is startup; Setup_Toolbar(Globals._Mode_current); picb_2DArea.Dock = picb_3DArea.Dock = DockStyle.Fill; Setup_ToolTips(); flagXe = false; }
// ########################################################################### // // P U B L I C // // ########################################################################### #region PUBLIC // =========================================================================== /// \brief Constructor // =========================================================================== public CtrlPendulum(Pendulum pendulum) { InitializeComponent( ); DoubleBuffered = true; // Register to pendulum updates pendulum.UpdatedEvent += EvPendulum_Updated; }
public float SinglePendAngleAcc(Pendulum pend) { float angleAcc; angleAcc = -Gravity / pend.length * Mathf.Sin(pend.angle); return(angleAcc); }
// Use this for initialization void Start() { Bob = new GameObject(); Bob = GameObject.CreatePrimitive(PrimitiveType.Sphere); line = gameObject.AddComponent <LineRenderer>(); line.positionCount = 2; line.widthMultiplier = 0.1f; pendulum = new Pendulum(new Vector3(16 / 2, 9, 0), 5f, 45f); }
private void Awake() { sphereRadius = GetComponent <SphereCollider>().radius; //groundBuffer = GetComponent<SphereCollider>().radius; hook = GetComponent <Pendulum>(); hook.enabled = false; Cursor.lockState = CursorLockMode.Locked; }
// =========================================================================== /// \brief Event when something changed in the pendulum /// /// Update the scopes to reflect the new data // =========================================================================== private void EvPendulum_Updated(Pendulum pendulum) { float tsMin, tsMax; tsMin = pendulum.TimestampMin / 1000.0f; tsMax = pendulum.Timestamp / 1000.0f; viewPositionMin = tsMin; viewSizeMax = tsMax - tsMin; // Ensure the view still agree with the pendulum data if (viewSizeMax < 1.0f) { viewSizeMax = 1.0f; } if (viewSize > viewSizeMax) { if (viewSizeMax > 10.0f) { viewSize = viewSizeMax; } else { viewSize = 10.0f; } } if (viewPosition < tsMin) { viewPosition = tsMin; } if (viewPosition + viewSize > tsMax) { viewPosition = tsMax - viewSize; } // Follow the data by sliding the view if needed if (follow) { viewPosition = tsMax - viewSize; } if (viewPosition < 0) { viewPosition = 0.0f; } // Chart must be refreshed if the view is beyond what as already been see if (viewPosition + viewSize >= bindLimit) { rebind = true; bindLimit = tsMax; } // Update charts to reflect the new view BeginInvoke(dlgtUpdateCharts); }
private void Awake() { thisPendulum = new Pendulum(); this.transform.RotateAround(anchor.transform.position, Vector3.right, initialAngle); thisPendulum.mass = massObject.GetComponent <PhysicsObject>().Mass; thisPendulum.length = transform.localScale.y; thisPendulum.angle = initialAngle * Mathf.Deg2Rad; }
void frmPendulum_Shown(object sender, EventArgs e) { p = new Pendulum(this.ClientRectangle.Width, this.ClientRectangle.Height); timer = new Timer() { Interval = 100 }; timer.Tick += delegate(object s2, EventArgs e2) { this.Refresh(); }; timer.Start(); }
public PenudulumSimulationControl() { InitializeComponent(); _updateTimer.Interval = 1000 / 60f; _updateTimer.Elapsed += UpdateTimer_Elapsed; Simulation = new Pendulum(SimulationCanvas); UpdateMotionLabelContent(); AddMotionLabels(); LengthTextBox.MaxLength = MaxTextBoxFieldWidth; DampingTextBox.MaxLength = MaxTextBoxFieldWidth; GravitationalFieldStrengthTextBox.MaxLength = MaxTextBoxFieldWidth; }
void Start() { // Create a new instance of the Pendulum behavior pendulum = gameObject.AddComponent <Pendulum>(); // Position the pivot for the pendulum at the top center of the camera pendulum.pivot = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width / 2, Screen.height)); // Pass the values into the new pendulum pendulum.gravity = gravity; pendulum.damping = damping; pendulum.radius = radius; // Adjust the angle since 0 degrees should point down, not up pendulum.angle = (180 - startingAngleDegrees) * Mathf.Deg2Rad; }
public float DoublePendleAngleAcc2(Pendulum pend1, Pendulum pend2) { float angleAcc; float num1 = 2 * Mathf.Sin(pend1.angle - pend2.angle); float num2 = (Mathf.Pow(pend1.angleVelocity, 2) * pend1.length * (pend1.mass + pend2.mass)); float num3 = gravity * (pend1.mass + pend2.mass) * Mathf.Cos(pend1.angle); float num4 = Mathf.Pow(pend2.angleVelocity, 2) * pend2.length * pend2.mass * Mathf.Cos(pend1.angle - pend2.angle); float den = pend2.length * (2 * pend1.mass + pend2.mass - (pend2.mass * Mathf.Cos(2 * pend1.angle - 2 * pend2.angle))); angleAcc = num1 * (num2 + num3 + num4) / den; return(angleAcc); }
public float DoublePendAngleAcc(Pendulum pend1, Pendulum pend2) { float angleAcc; float num1 = -gravity * (2 * pend1.mass + pend2.mass) * Mathf.Sin(pend1.angle); float num2 = -pend2.mass * gravity * Mathf.Sin(pend1.angle - 2 * pend2.angle); float num3 = -2 * Mathf.Sin(pend1.angle - pend2.angle) * pend2.mass; float num4 = Mathf.Pow(pend2.angleVelocity, 2) * pend2.length + Mathf.Pow(pend1.angleVelocity, 2) * pend1.length * Mathf.Cos(pend1.angle - pend2.angle); float den = pend1.length * (2 * pend1.mass + pend2.mass - (pend2.mass * Mathf.Cos(2 * pend1.angle - 2 * pend2.angle))); angleAcc = (num1 + num2 + num3 * num4) / den; return(angleAcc); }
// Use this for initialization void Start() { control = GameObject.FindGameObjectWithTag("Player").GetComponent <Control>(); a = pendulum.GetComponent <Pendulum>(); s = GetComponent <SpriteRenderer>(); coli = GetComponent <Collider2D>(); if (PlayerPrefs.GetInt("Newgame") == 1) { PlayerPrefs.SetInt(gameObject.name, 0); } if (PlayerPrefs.GetInt(gameObject.name) == 1) { Disable(); } }
// ########################################################################### // // P U B L I C // // ########################################################################### #region PUBLIC // =========================================================================== /// \brief Control constructor /// /// \param[in] pendulum Pendulum we display information from // =========================================================================== public CtrlParamDisplay(Pendulum pendulum) { InitializeComponent( ); // Connect to pendulum model this.pendulum = pendulum; pendulum.UpdatedEvent += EvPendulum_Updated; fontValue = lblParamValue.Font; fontDescription = new Font(lblParamValue.Font.FontFamily, 10.0f); fontParamName = new Font(lblParamValue.Font.FontFamily, 10.0f, FontStyle.Bold); fontParamValue = new Font(lblParamValue.Font.FontFamily, 11.0f, FontStyle.Italic); lblParamName.Text = "iPendulum CS"; lblParamValue.Text = ""; this.DoubleBuffered = true; }
// Use this for initialization void Awake() { Cursor.lockState = CursorLockMode.Confined; Cursor.visible = false; grapplingPoint = transform.Find("grapplingPoint"); cc2d = GetComponent <CapsuleCollider2D>(); player = this; rb = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); grapplingHook = GetComponent <Pendulum>(); currentBulletSpawnPoint = defaultBulletSpawnPoint; if (hookAbilityFound) { ShowGrapplingHookChains(false); } cam = Camera.main; }
// ########################################################################### // // P R I V A T E // // ########################################################################### #region PRIVATE // =========================================================================== /// \brief Pendulum status changed. Control is repainted. /// /// \param pendulum Pendulum data model. // =========================================================================== private void EvPendulum_Updated(Pendulum pendulum) { bool redraw = false; float bAngle; bAngle = pendulum.StateBodyAngle; if (Math.Abs(pendulumAngle - bAngle) > 0.001) { pendulumAngle = bAngle; redraw = true; } if (soc != pendulum.BatterySOC) { soc = pendulum.BatterySOC; redraw = true; } if (redraw) { this.Invalidate( ); } }
// ########################################################################### // // P R I V A T E // // ########################################################################### #region PRIVATE // =========================================================================== /// \brief Pendulum status changed. Control is repainted. /// /// \param pendulum Pendulum. // =========================================================================== private void EvPendulum_Updated(Pendulum pendulum) { // Redraw the control if there is an update of the parameters Invalidate( ); }
// Use this for initialization void Start() { pend = GetComponent <Pendulum>(); }
public PendulumState(Pendulum <T, K> pendulum) { this.pendulum = pendulum; }
// =========================================================================== /// \brief Attach this control to a a pendulum // =========================================================================== public void AttachPendulum(Pendulum pendulum) { this.pendulum = pendulum; pendulum.UpdatedEvent += EvPendulum_Updated; }
private void InitializePendulum() { pendulum = new Pendulum((int)attractors.Value); SetParameters(); }
private void Awake() { thisPendulum = new Pendulum(); otherPendulum = new Pendulum(); }