static int Main() { long testResult = 0; int mainResult = 0; Point1 p1 = new Point1(1); Point1 p2 = new Point1(3); Point1 p3 = new Point1(5); arr = new long[3]; arr[0] = 9; arr[1] = 10; arr[2] = 11; testResult = Test(3, p1, p2, p3); if (testResult != 39) { Console.WriteLine("FAILED!"); mainResult = -1; } else { Console.WriteLine("passed"); mainResult = 100; } return(mainResult); }
internal QuadraticBezierSegment ToNative() { return(new QuadraticBezierSegment { Point1 = Point1.ToD2DVector(), Point2 = Point2.ToD2DVector() }); }
public override int GetHashCode() { unchecked { return((Point1.GetHashCode() * 397) ^ Point2.GetHashCode()); } }
static void Main() { var p1 = new Point1(1, 2); Console.WriteLine((p1.GetMember(0), p1.GetMember(1))); var p2 = new Point2(1, 2); Console.WriteLine((p2.GetMember("X"), p2.GetMember("Y"))); var p3 = new Point3(1, 2); foreach (var t in p3.EnumerateMembers()) { Console.WriteLine(t); } var p = new Point(1, 2); Console.WriteLine((p.GetMember(0), p.GetMember(1))); Console.WriteLine((p.GetMember("X"), p.GetMember("Y"))); foreach (var t in p3.EnumerateMembers()) { Console.WriteLine(t); } }
public LineSegment2D RotateAroundReferencePoint(double angleInDegrees, Point2D referencePoint) { var newPoint1 = Point1.RotateAroundReferencePoint(angleInDegrees, referencePoint); var newPoint2 = Point2.RotateAroundReferencePoint(angleInDegrees, referencePoint); return(new LineSegment2D(newPoint1, newPoint2)); }
private void UpdateMedium() { MyPoint different = EndPoint - StartPoint; Point1.Set(StartPoint.X + 3 * different.X / 8, StartPoint.Y + 1 * different.Y / 8); Point2.Set(StartPoint.X + 5 * different.X / 8, StartPoint.Y + 7 * different.Y / 8); }
unsafe static long Test(int size, Point1 a, Point1 b, Point1 c) { // Mutate the values stored in a, b and c // So if these have a shadow copy we will notice // a.Increase(ref a, arr[0]); b.Increase(ref b, arr[1]); c.Increase(ref c, arr[2]); DangerousBuffer db = new DangerousBuffer(); db.a = -1; db.b = -2; db.c = -3; long *x1 = stackalloc long[size]; long sum = 0; if (size >= 3) { x1[0] = a.Value(); x1[1] = b.Value(); x1[2] = c.Value(); for (int i = 0; i < size; i++) { sum += x1[i]; } } return(sum); }
public LineSegment2D RotateAroundOrigin(double angleInDegrees) { var newPoint1 = Point1.RotateAroundOrigin(angleInDegrees); var newPoint2 = Point2.RotateAroundOrigin(angleInDegrees); return(new LineSegment2D(newPoint1, newPoint2)); }
public Line2 Translate(IVector2 translation) { Line2 lineOut = new Line2(Point1.Plus(translation), Point2.Plus(translation)); lineOut.Col = Col; return(lineOut); }
public ILine3 Translate(IVector3 translation) { ILine3 lineOut = new Line3(Point1.Plus(translation), Point2.Plus(translation)); lineOut.Col = Col; return(lineOut); }
public void Read(BinaryReader r) { center = new Point1(); center.Read(r); rad = r.ReadInt32(); fIsNull = BitConverter.ToBoolean(r.ReadBytes(1), 0); }
protected override void UpdateUIRepresentationCore() { base.UpdateUIRepresentationCore(); Viewport2D viewport = Plotter.Viewport; double deltaX = Point1.X - Point2.X; double deltaY = Point1.Y - Point2.Y; double m = deltaY / deltaX; double b = Point1.Y - Point1.X * deltaY / deltaX; Func <double, double> func = x => m * x + b; double xMin = viewport.Visible.XMin; double xMax = viewport.Visible.XMax; Point p1 = new Point(xMin, func(xMin)).DataToScreen(viewport.Transform); Point p2 = new Point(xMax, func(xMax)).DataToScreen(viewport.Transform); if (direction > 0) { p1 = Point2.DataToScreen(viewport.Transform); } else { p2 = Point1.DataToScreen(viewport.Transform); } geometry.StartPoint = p1; geometry.EndPoint = p2; }
public override string ToString() { string slope_symbol = ""; int vertical_slope_limit = 100; if (Slope == 0) { slope_symbol = "_"; } else if (Slope > 0 && Slope < vertical_slope_limit) { slope_symbol = "/"; } else if (Slope < 0 && Slope > -vertical_slope_limit) { slope_symbol = "\\"; } else { slope_symbol = "|"; } string line = Point1.ToString() + "-" + Point2.ToString() + " " + slope_symbol; return(line); }
static void Main(string[] args) { /********* VALUE TYPES *********/ int x = 5; ChangeValue(x); //only set to 10 in this method, one method completes program will go back to using x value in the main arguments scope. This application will print out x being equal to 5. Console.WriteLine("X: {0}", x); /********* REFERENCE TYPES *********/ Point1 p1 = new Point1(); //reference types are usually classes and arrays p1.X = 5; p1.Y = 10; Point1 p2 = p1; Point1 p3 = p2; p3.Y = 50; Console.WriteLine(p2.Y); Point2 p10 = new Point2(); p10.X = 10; p10.Y = 5; ChangePoint(p10); Console.WriteLine("X: {0}, Y:{1}", p10.X, p10.Y); Console.ReadLine(); }
public bool IsLine() { if (Point1.isequal(Point2)) { return(false); } return(true); }
internal Triangle ToNative() { return(new Triangle { Point1 = Point1.ToD2DVector(), Point2 = Point2.ToD2DVector(), Point3 = Point3.ToD2DVector() }); }
public override int GetHashCode() { var hashCode = 363529913; hashCode = hashCode * -1521134295 + Point1.GetHashCode(); hashCode = hashCode * -1521134295 + Point2.GetHashCode(); return(hashCode); }
internal BezierSegment ToNative() { return(new BezierSegment { Point1 = Point1.ToD2DVector(), Point2 = Point2.ToD2DVector(), Point3 = Point3.ToD2DVector() }); }
private void SetTransform() { Transform.Position = (Point1.To <decimal>() + Point2.To <decimal>()) / 2.0m; var diff = (Point2 - Point1); diff = new Vector3 <long>(Math.Abs(diff.X), Math.Abs(diff.Y), Math.Abs(diff.Z)); Transform.Scale = diff.To <float>() + 1.01f; }
public override void ToFoamDictionary(FoamDictionary fd) { fd.SetChild("type", "cone"); fd.SetChild("p0", Point0.ToString()); fd.SetChild("p1", Point1.ToString()); fd.SetChild("radius0", Radius0); fd.SetChild("radius1", Radius1); }
private void SetupConnectors() { Input = new ConnectorViewModel(NodesCanvas, this, "Input", Point1.Addition(0, 30)); Output = new ConnectorViewModel(NodesCanvas, this, "Output", Point1.Addition(80, 54)) { Visible = null }; AddEmptyConnector(); }
public ILine3 RotateY(IVector3 rotationPt, double angleRad) { ILine3 lineRot = new Line3(); lineRot.Point1 = Point1.RotateY(rotationPt, angleRad); lineRot.Point2 = Point2.RotateY(rotationPt, angleRad); lineRot.Col = Col; return(lineRot); }
public void Point1XML() { int money = 4000; var actual = from customer in Point1.GetAnswer(doc, money) select customer.Element("id").Value; Assert.IsTrue(actual.First().Equals("ALFKI")); }
public override void Draw() { Console.ForegroundColor = consoleColor; Console.WriteLine("Drawed a " + Color + " line " + Name); Console.WriteLine("and the points it go though is "); Point1.Output(); Point2.Output(); Console.ResetColor(); }
public double Square() { double p = Perimiter() / 2; double sideA = Point1.Distance(Point2); double sideB = Point2.Distance(Point3); double sideC = Point3.Distance(Point1); return(Math.Sqrt(p * (p - sideA) * (p - sideB) * (p - sideC))); }
public Line2 RotateZ(IVector3 rotationPt, double angleRad) { Line2 lineRot = new Line2(); lineRot.Point1 = Point1.RotateZ(rotationPt, angleRad); lineRot.Point2 = Point2.RotateZ(rotationPt, angleRad); lineRot.Col = Col; return(lineRot); }
// Make a deep copy of this object public override GroundedClause DeepCopy() { Segment other = (Segment)(this.MemberwiseClone()); other.Point1 = (Point)Point1.DeepCopy(); other.Point2 = (Point)Point2.DeepCopy(); return(other); }
public XElement ToXml(string name) { return(new XElement(name, Point1.ToXml("P1"), Point2.ToXml("P2"), Point3.ToXml("P3"), Point4.ToXml("P4") )); }
public static bool operator !=(Point Point1, Point Point2) { //if ((Point1.XCoordinate == Point2.XCoordinate) && // (Point1.YCoordinate == Point2.YCoordinate)) // return (false); //else // return (true); return(!Point1.Equals(Point2)); }
public override int GetHashCode() { var hash = 0; hash = Utils.Misc.CombineHashCodes(new[] { hash, Type.Value.GetHashCode() }); if (Type.Value == ProcedualModelType.Mesh) { hash = Utils.Misc.CombineHashCodes(new[] { hash, AngleBeginEnd.X.Value.GetHashCode(), AngleBeginEnd.Y.Value.GetHashCode(), Divisions.GetValueHashCode() }); } else if (Type.Value == ProcedualModelType.Ribbon) { hash = Utils.Misc.CombineHashCodes(new[] { hash, CrossSection.Value.GetHashCode(), Rotate.Value.GetHashCode(), Vertices.Value.GetHashCode(), RibbonScales.GetValueHashCode(), RibbonAngles.GetValueHashCode(), RibbonNoises.GetValueHashCode(), Count.Value.GetHashCode() }); } else { throw new Exception(); } hash = Utils.Misc.CombineHashCodes(new[] { hash, PrimitiveType.Value.GetHashCode() }); if (PrimitiveType.Value == ProcedualModelPrimitiveType.Sphere) { hash = Utils.Misc.CombineHashCodes(new[] { hash, DepthMin.Value.GetHashCode(), DepthMax.Value.GetHashCode(), Radius.Value.GetHashCode() }); } else if (PrimitiveType.Value == ProcedualModelPrimitiveType.Cone) { hash = Utils.Misc.CombineHashCodes(new[] { hash, Depth.Value.GetHashCode(), Radius.Value.GetHashCode() }); } else if (PrimitiveType.Value == ProcedualModelPrimitiveType.Cylinder) { hash = Utils.Misc.CombineHashCodes(new[] { hash, Depth.Value.GetHashCode(), Radius.Value.GetHashCode(), Radius2.Value.GetHashCode() }); } else if (PrimitiveType.Value == ProcedualModelPrimitiveType.Spline4) { hash = Utils.Misc.CombineHashCodes(new[] { hash, Point1.GetValueHashCode(), Point2.GetValueHashCode(), Point3.GetValueHashCode(), Point4.GetValueHashCode() }); } else { throw new Exception(); } hash = Utils.Misc.CombineHashCodes(new[] { hash, AxisType.Value.GetHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, TiltNoiseFrequency.GetValueHashCode(), TiltNoiseOffset.GetValueHashCode(), TiltNoisePower.GetValueHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, WaveNoiseFrequency.GetValueHashCode(), WaveNoiseOffset.GetValueHashCode(), WaveNoisePower.GetValueHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, CurlNoiseFrequency.GetValueHashCode(), CurlNoiseOffset.GetValueHashCode(), CurlNoisePower.GetValueHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, ColorLeft.GetValueHashCode(), ColorCenter.GetValueHashCode(), ColorRight.GetValueHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, ColorLeftMiddle.GetValueHashCode(), ColorCenterMiddle.GetValueHashCode(), ColorRightMiddle.GetValueHashCode() }); hash = Utils.Misc.CombineHashCodes(new[] { hash, ColorCenterArea.GetValueHashCode() }); return(hash); }
public void Redraw() { Path.ClearPoints(); var startPoint = Point1.GetOffset(Point1.Item.Margin); var endPoint = Point2.GetOffset(Point2.Item.Margin); var path = Designer.GetPath(startPoint, endPoint); Path.AddPoint(Point2.GetOffset(Point2.ConnectionPointSize)); Path.AddPoints(path); Path.AddPoint(Point1.GetOffset(Point2.ConnectionPointSize)); }
public static void StructVsClass() { Str[] s = new Str[100]; var str = s[50].str1; Point1[] a = new Point1[1000]; int x = a[500].X; Point2[] b = new Point2[1000]; int y = b[500].X; Console.WriteLine(str); Console.WriteLine(x); Console.WriteLine(y); Console.ReadKey(); }
public static void TestPakaging2() { Point1 p = new Point1(1, 1); Console.WriteLine(p); p.Change(2, 2); Console.WriteLine(p); Object o = p; Console.WriteLine(o); ((Point1)o).Change(3, 3); // При таком приведении типа o распаковывается, и поля упакованного объекта типа Point копируются во временный объект типа Point в стеке потока. Поля m_x и m_y этого временного объекта устанавливаются равными 3, но это обращение к Change не влияет на упакованный объект Point. При обращении к WriteLine снова выводится (2, 2). Для многих разработчиков это оказывается неожиданным. Console.WriteLine(o); Point2 p2 = new Point2(1, 1); Console.WriteLine(p2); p2.Change(2, 2); Console.WriteLine(p2); Object o2 = p2; Console.WriteLine(o2); ((Point2)o2).Change(3, 3); Console.WriteLine(o2); // p упаковывается, упакованный объект изменяется и освобождается ((IChangeBoxedPoint)p2).Change(4, 4); Console.WriteLine(p2); // 2 2 // Упакованный объект изменяется и выводится ((IChangeBoxedPoint)o2).Change(5, 5); Console.WriteLine(o2); // 5 5 }