public static Point DecToPoint(Dec dec, double degreeA, double degreeB, int grab, int time) { try { axisB = new Dec(); axisC = new Dec(); //axisC.decZ = dec.decZ + Math.Sin(180 / Math.PI * degreeB) * L3; //axisC.pXY = dec.pXY + Math.Cos(180 / Math.PI * degreeB) * L3; axisC.decZ = dec.decZ + Math.Sin(-(degreeB + 90) * Math.PI / 180) * L3; //coord Y axisC.pXY = dec.pXY + Math.Cos(-(degreeB + 90) * Math.PI / 180) * L3; //coord X axisC.decX = dec.decX * axisC.pXY / dec.pXY; axisC.decY = dec.decY * axisC.pXY / dec.pXY; if (axisC.decY < 0 || axisC.pXY < 0) { throw new Exception("К данной координате нельзя переместиться."); } axisB = Shape.Algoritm(axisC); var AC = Math.Sqrt(axisC.pXY * axisC.pXY + axisC.decZ * axisC.decZ); int CanA = Convert.ToInt32(Math.Acos(dec.decX / dec.pXY) * 180 / Math.PI) - 90; int CanB = Convert.ToInt32(Math.Acos(axisB.pXY / Shape.L1) * 180 / Math.PI); int CanC = 180 - Convert.ToInt32(Math.Acos((AC * AC - Shape.L1 * Shape.L1 - Shape.L2 * Shape.L2) / (2 * Shape.L1 * Shape.L2)) * 180 / Math.PI); int CanD = -90 + CanB + CanC + Convert.ToInt32(degreeB); int CanE = Convert.ToInt32(degreeA); return(new Point(CanA, CanB, CanC, CanD, CanE, grab, time)); } catch (Exception e) { throw new Exception(e.Message); } }
protected void testDes() { //string testStr = "asdfasdf5"; //byte[] inBytes = System.Text.Encoding.UTF8.GetBytes(testStr); //byte[] key = { 0x65, 0xC1, 0x78, 0xB2, 0x84, 0xD1, 0x97, 0xCC }; byte[] key = { 26, 32, 127, 193, 251, 239, 174, 97 }; //byte[] inBytes = { 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1, 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1 }; byte[] inBytes = { 0x0c, 0x00, 0x00, 0x00, 0x03, 0x35, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] outBytes = new byte[16]; uint inSize = (uint)inBytes.Length; DES_key_schedule des5Key = new DES_key_schedule(); // RC5 key Dec.DES_set_key_unchecked(key, des5Key); CryptContext cryptContext = new CryptContext(); cryptContext.m_cryptAlgorithm = CryptAlgorithm.DES; cryptContext.setCryptKey(key); //Crypt.encryptData(inBytes, 0, 16, ref outBytes, des5Key, CryptAlgorithm.DES); //Crypt.decryptData(outBytes, 0, 16, ref inBytes, des5Key, CryptAlgorithm.DES); //testStr = System.Text.Encoding.UTF8.GetString(inBytes); Crypt.decryptData(inBytes, 0, 16, ref outBytes, cryptContext); }
public void CreateDecimalTest2() { var d = Dec.Create(0.33333333333333m); Assert.AreEqual(d, Literal.Create(1) / Literal.Create(3)); Assert.AreEqual(d.ToString(), "0.33333333333333"); }
public static void Problem_36() { int Answer = 0; int Dec; string DecReversed = ""; char[] DecChars; char[] BinChars; string Bin; string BinReversed = ""; for (int i = 0; i < 1000000; i++) { Dec = i; DecChars = Dec.ToString().ToCharArray(); DecReversed = ""; for (int j = DecChars.Length - 1; j >= 0; j--) { DecReversed += DecChars[j]; } if (Dec == int.Parse(DecReversed)) { Bin = Convert.ToString(Dec, 2); BinReversed = ""; BinChars = Bin.ToCharArray(); for (int j = Bin.Length - 1; j >= 0; j--) { BinReversed += BinChars[j]; } if (Bin == BinReversed) { Answer += i; } } } Console.WriteLine("The sum of all circular primes is " + Answer); }
public static void Main(String[] args) { Console.WriteLine("CO_Interlocked ..."); Fred f = new Fred( ); Inc inc = new Inc(f); Dec dec = new Dec(f); Thread Incer = new Thread(new ThreadStart(inc.ThreadStart)); Thread Incer2 = new Thread(new ThreadStart(inc.ThreadStart)); Thread Decer = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer2 = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer3 = new Thread(new ThreadStart(dec.ThreadStart)); try { Incer.Start( ); Incer2.Start( ); Decer.Start( ); Decer2.Start( ); Decer3.Start( ); Incer.Join( ); Incer2.Join( ); Decer.Join( ); Decer2.Join( ); Decer3.Join( ); } catch (ThreadStateException e) { Console.WriteLine(e); } catch (ThreadInterruptedException e) { Console.WriteLine(e); } Console.WriteLine("... CO_Interlocked"); Environment.ExitCode = 0; return; }
public void CreateDecimalTest() { var d = Dec.Create(0.5m); Assert.AreEqual(d, Literal.Create(1) / Literal.Create(2)); Assert.AreEqual(d.ToString(), "0.5"); }
static void Main(string[] args) { Dec dec = new Dec(12); CheckRules checks = new CheckRules(); CheckRules subc = new CheckRules(); subc.Add(Operator.NONE, new CheckRule(Operator.LT, 12)); CheckRules subcc = new CheckRules(); subcc.Add(Operator.NONE, new CheckRule(Operator.GT, 10)); dec.SetCheckRules( checks .Add(Operator.NONE, new CheckRule(Operator.LT, 13)) .Add(Operator.AND, new CheckRule(Operator.GT, 11)) .Add(Operator.OR, subc.Add(Operator.AND, subcc)) ); Trace.WriteLine(dec.IsNotNull()); Trace.WriteLine(dec.HasValidValue()); Trace.WriteLine("End"); }
public static void Main(String[] args) { Console.WriteLine("CO_Interlocked ..."); Fred f = new Fred( ); Inc inc = new Inc(f); Dec dec = new Dec(f); Thread Incer = new Thread(new ThreadStart(inc.ThreadStart)); Thread Incer2 = new Thread(new ThreadStart(inc.ThreadStart)); Thread Decer = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer2 = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer3 = new Thread(new ThreadStart(dec.ThreadStart)); try { Incer.Start( ); Incer2.Start( ); Decer.Start( ); Decer2.Start( ); Decer3.Start( ); Incer.Join( ); Incer2.Join( ); Decer.Join( ); Decer2.Join( ); Decer3.Join( ); } catch (ThreadStateException e) {Console.WriteLine(e);} catch (ThreadInterruptedException e) {Console.WriteLine(e);} Console.WriteLine("... CO_Interlocked"); Environment.ExitCode = 0; return; }
public void CloneTest() { var exp = new Dec(Variable.X); var clone = exp.Clone(); Assert.Equal(exp, clone); }
public Gen <Commands.ICommand <Counter, int> > GenCommand(int _) { var g1 = new Inc() as Commands.ICommand <Counter, int>; var g2 = new Dec() as Commands.ICommand <Counter, int>; return(Any.ValueIn(g1, g2)); }
[Test] public void Add() { rec.Enter(forward: false); var dec = new Dec(); rec.Add(dec); o(rec.Peek()[0], dec); }
public Node StatementDec() { Expect(TokenCategory.DEC); var dec = new Dec(); Expect(TokenCategory.SEMICOL); return(dec); }
public void DecBoolTest() { var parameters = new ParameterCollection() { new Parameter("x", true) }; var dec = new Dec(Variable.X); Assert.Throws <NotSupportedException>(() => dec.Execute(parameters)); }
public void DecCalcTest() { var parameters = new ParameterCollection() { new Parameter("x", 10) }; var dec = new Dec(Variable.X); var result = (double)dec.Execute(parameters); Assert.Equal(9.0, result); Assert.Equal(9.0, parameters["x"]); }
[Test] public void CxIndexer_didReset([Range(-1, 1)] int val) { var cx = rec.Enter(forward: false); var dec = new Dec(); rec.Add(dec); status s = status.@unchecked(val); s = cx[s]; o(dec.didReset, !s.running); o(rec.Count, 0); }
[Test] public void Indexer([Range(-1, 1)] int val, [Values(null, "foo")] string crit) { var dec = new Dec(); x.Check(crit, stack); // trigger x (enter cx) x.context?.Traverse(dec); // traverse a decorator var s0 = status.@unchecked(val); var s1 = x[s0]; // exit the context o(dec.didReset, crit == "foo"); // did reset o(s0, s1); // neutrality }
// rc5 加密后大小不会变化的 static public bool DES_ECB_Symmetry_Encode_OpenSSL(byte[] encryptByte, uint startPos, uint inLen, ref byte[] outBytes, DES_key_schedule rgbKey, CryptContext cryptContext) { try { Dec.DES_ecb_encrypt_one(encryptByte, startPos, inLen, ref outBytes, rgbKey, RC5.RC5_ENCRYPT, cryptContext); return(true); } catch { Ctx.m_instance.m_logSys.error("DES_ECB_Symmetry_Encode_OpenSSL error"); return(false); } }
/// <summary> /// Устанавливает положение манипулятора в исходное состояние /// </summary> public void Home() { try { if (checkAlgoritm.Checked) { if ((string)comboHomeMode.SelectedItem == "work") { Point homePoint = new Point(0, 0, 8, 0, 245, 0); Point.tempPoint = homePoint; serialPort.Write(homePoint); trackBarSet(homePoint); } else if ((string)comboHomeMode.SelectedItem == "steady") { Point homePoint = new Point(0, 45, 87, 0, 240, 0); Point.tempPoint = homePoint; serialPort.Write(homePoint); trackBarSet(homePoint); } } else { if ((string)comboHomeMode.SelectedItem == "work") { //Dec homeDec = new Dec(0, 85, 135, 120, 0); //trackBarSet(homeDec); //trackBar_A_Scroll(new object(), new EventArgs()); Point homePoint = new Point(0, 53, 95, 0, 245, 0); Dec homeDec = DecPointTransform.PointToDec(homePoint); trackBarSet(homeDec); trackBar_D_Scroll(new object(), new EventArgs()); } else if ((string)comboHomeMode.SelectedItem == "steady") { Point homePoint = new Point(0, 150, 54, 120, 0, 155); Dec homeDec = DecPointTransform.PointToDec(homePoint); trackBarSet(homeDec); trackBar_D_Scroll(new object(), new EventArgs()); } } } catch (Exception ce) { MessageBox.Show(ce.ToString(), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Start is called before the first frame update void Start() { bFond = bFond.GetComponent <Button>(); bFond.onClick.AddListener(UpdateFond); Count = 1; inventaire = inventaire.GetComponent <Inventaire>(); button = GetComponent <Button>(); button.onClick.AddListener(TaskOnClick); Inc = Inc.GetComponent <Button>(); Dec = Dec.GetComponent <Button>(); Inc.onClick.AddListener(Increment); Dec.onClick.AddListener(Decrement); text.text = Count.ToString() + " / " + maxCount(recettecraft).ToString(); }
public Node StmtDec() { var result = new Dec() { AnchorToken = Expect(TokenCategory.DEC) }; result.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); Expect(TokenCategory.SEMICOLON); return(result); }
[Test] public void Indexer([Range(-1, 1)] int val, [Values(true, false)] bool arg) { var dec = new Dec(); // init. with condition x = new Reckoning(arg, stack); x.context?.Traverse(dec); // traverse a decorator var s0 = status.@unchecked(val); var s1 = x[s0]; // exit the context o(dec.didReset, arg); // did reset? o(s0, s1); // neutrality }
private void Drav(int decX, int decY) { try { Text = "Норм"; Graphics gr = pictureBox1.CreateGraphics(); gr.Clear(Color.White); //Рисует систему координат gr.DrawLine(new Pen(Brushes.Black), 0, (maxY - 1) / 2 + 1, maxX, (maxY - 1) / 2 + 1); gr.DrawLine(new Pen(Brushes.Black), (maxX - 1) / 2 + 1, 0, (maxX - 1) / 2 + 1, maxY); axisC = new Dec(); axisC.decZ = decY + Math.Sin(-(T_degreeB.Value + 90) * Math.PI / 180) * L3; //coord Y axisC.decY = decX + Math.Cos(-(T_degreeB.Value + 90) * Math.PI / 180) * L3; //coord X axisC.update_pXY(); axisB = Shape.Algoritm(axisC); // axisB.decY= coord X, axisB.decZ= coord Y DrawCircle(0, 0, Convert.ToInt32(Shape.L1), new Pen(Brushes.Red)); DrawCircle((int)axisC.pXY, (int)axisC.decZ, Convert.ToInt32(Shape.L2), new Pen(Brushes.GreenYellow)); DrawCircle(decX, decY, Convert.ToInt32(L3), new Pen(Brushes.Blue)); DrawLine(0, 0, (int)axisB.pXY, (int)axisB.decZ); DrawLine((int)axisB.decY, (int)axisB.decZ, (int)axisC.decY, (int)axisC.decZ); DrawLine((int)axisC.decY, (int)axisC.decZ, decX, decY); DrawCircle(0, 0, 3, new Pen(Brushes.Black)); DrawCircle((int)axisB.decY, (int)axisB.decZ, 3); DrawCircle((int)axisC.decY, (int)axisC.decZ, 3); DrawCircle(decX, decY, 3); var AC = Math.Sqrt(axisC.decZ * axisC.decZ + axisC.decY * axisC.decY); int CanB = Convert.ToInt32(Math.Acos(axisB.decY / Shape.L1) * 180 / Math.PI); valueQ2.Text = CanB.ToString(); int CanC = 180 - Convert.ToInt32(Math.Acos((AC * AC - Shape.L1 * Shape.L1 - Shape.L2 * Shape.L2) / (2 * Shape.L1 * Shape.L2)) * 180 / Math.PI); valueQ3.Text = CanC.ToString(); int CanD = -90 + CanB + CanC + T_degreeB.Value; valueQ4.Text = CanD.ToString(); } catch (Exception e) { Text = e.ToString(); } }
//----------------------------------------------------------- public void Visit(Dec node) { var variableName = node.AnchorToken.Lexeme; if (Table[funName].table.Contains(variableName) || GlobalVars.Contains(variableName)) { VisitChildren(node); } else { throw new SemanticError( "Undeclared variable: " + variableName, node.AnchorToken); } }
public string Visit(Dec node) { var sb = new StringBuilder(); var variableName = node[0].AnchorToken.Lexeme; var props = FunTable[currentFunction]; if (props.reference.ContainsKey(variableName)) { sb.Append($" local.set ${variableName}\n"); } else { sb.Append($" global.set ${variableName}\n"); } return(Visit((dynamic)node[0]) + $" i32.const 1\n" + $" i32.sub\n" + sb.ToString()); }
void MakeDecal(Vector3 D, Vector3 N) { GameObject Dec; if (N == Vector3.zero) { Dec = Instantiate(Decal, D, Quaternion.identity); } else { Dec = Instantiate(Decal, D, Quaternion.LookRotation(N, Vector3.up)); } Vector3[] Pos = new Vector3[2]; Pos[0] = FirePosition.transform.position; Pos[1] = D; Dec.GetComponent <LineRenderer>().SetPositions(Pos); }