コード例 #1
0
 public void YTest()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D ); // TODO: 初始化为适当的值
     float expected = 0F; // TODO: 初始化为适当的值
     float actual;
     target.Y = expected;
     actual = target.Y;
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
コード例 #2
0
 /// <summary>
 /// Converts the given string value into a double, Point, Point3D, or Color.
 /// </summary>
 private static void ConvertValue(string valueText, Type type, ref object value)
 {
     try
     {
         if (type == typeof(double))
         {
             value = Double.Parse(valueText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
         }
         else if (type == typeof(float))
         {
             value = Single.Parse(valueText, NumberStyles.Any, NumberFormatInfo.InvariantInfo);
         }
         else if (type == typeof(Point))
         {
             value = Point.Parse(valueText);
         }
         else if (type == typeof(Size))
         {
             value = Size.Parse(valueText);
         }
         else if (type == typeof(Vector))
         {
             value = Vector.Parse(valueText);
         }
         else if (type == typeof(Point3D))
         {
             value = Point3D.Parse(valueText);
         }
         else if (type == typeof(Vector3D))
         {
             value = Vector3D.Parse(valueText);
         }
         else if (type == typeof(Point4D))
         {
             value = Point4D.Parse(valueText);
         }
         else if (type == typeof(Color))
         {
             value = ColorConverter.ConvertFromString(valueText);
         }
     }
     catch
     {
     }
 }
コード例 #3
0
        bool BlDataOverFlow(Point4D p, int pos)
        {
            try
            {
                return(true);

                int index = NoCamera * ParCameraWork.P_I[NoCamera] + pos;

                if (p.DblValue1 < ParSetRobot.P_I.dataLimitRobot_L[index].DblXMin ||
                    p.DblValue1 > ParSetRobot.P_I.dataLimitRobot_L[index].DblXMax

                    || p.DblValue2 <ParSetRobot.P_I.dataLimitRobot_L[index].DblYMin ||
                                    p.DblValue2> ParSetRobot.P_I.dataLimitRobot_L[index].DblYMax

                    || p.DblValue3 <ParSetRobot.P_I.dataLimitRobot_L[index].DblRMin ||
                                    p.DblValue3> ParSetRobot.P_I.dataLimitRobot_L[index].DblRMax

                    || p.DblValue4 <ParSetRobot.P_I.dataLimitRobot_L[index].DblTMin ||
                                    p.DblValue4> ParSetRobot.P_I.dataLimitRobot_L[index].DblTMax
                    )
                {
                    string strStd = ParSetRobot.P_I.dataLimitRobot_L[index].DblXMin.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblXMax.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblYMin.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblYMax.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblRMin.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblRMax.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblTMin.ToString() + ","
                                    + ParSetRobot.P_I.dataLimitRobot_L[index].DblTMax.ToString();
                    if (ParSetRobot.P_I.BlDataOverflow)
                    {
                        string strError = "Camera" + NoCamera.ToString() + "Pos" + pos.ToString() + ":Error:" + p.strValue + ",Std:" + strStd;
                        DataError_event(strError);
                        LogComInterface.L_I.WriteData("Overflow", strError);
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError("LogicRobot", ex);
                return(false);
            }
        }
コード例 #4
0
 /// <summary>
 /// 发送一个点位加命令
 /// </summary>
 /// <param name="point">点数据</param>
 /// <param name="cmd">命令</param>
 public void WriteRobotCMD(Point4D point, string cmd)
 {
     try
     {
         string value = Head
                        + point.DblValue1.ToString("f2").PadLeft(7, ' ') + " "
                        + point.DblValue2.ToString("f2").PadLeft(7, ' ') + " "
                        + point.DblValue3.ToString("f2").PadLeft(7, ' ') + " "
                        + point.DblValue4.ToString("f2").PadLeft(7, ' ') + " "
                        + "0".PadLeft(7, ' ') + " "
                        + cmd.PadLeft(7, ' ');
         WriteRobot(value);
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError("LogicRobot", ex);
     }
 }
コード例 #5
0
        private string point4DEqualityExample()
        {
            // <SnippetPoint4DEqualityExample_csharp>
            // instantiate Points
            Point4D point4D1 = new Point4D();
            Point4D point4D2 = new Point4D(15, 40, 60, 75);
            Point3D point3D1 = new Point3D(15, 40, 60);

            // result variables
            Boolean areEqual;
            Boolean areNotEqual;
            String  stringResult;

            // defining x,y,z,w of point1
            point4D1.X = 10;
            point4D1.Y = 5;
            point4D1.Z = 1;
            point4D1.W = 4;

            // checking if Points are equal
            areEqual = point4D1 == point4D2;

            // areEqual is False

            // checking if Points are not equal
            areNotEqual = point4D1 != point4D2;
            // areNotEqual is True

            if (Point4D.Equals(point4D1, point3D1))
            {
                // the if condition is not true, so this block will not execute
                stringResult = "Both objects are Point4D structures and they are equal";
            }

            else
            {
                // the if condition is false, so this branch will execute
                stringResult = "Parameters are not both Point4D strucutres, or they are but are not equal";
            }
            // </SnippetPoint4DEqualityExample_csharp>

            return(stringResult);
        }
コード例 #6
0
 public void SendDataNG93_Camera(Point4D p)
 {
     try
     {
         string cmd   = NoCamera.ToString() + "93";//命令
         string value = Head
                        + p.DblValue1.ToString("f2").PadLeft(7, ' ') + " "
                        + p.DblValue2.ToString("f2").PadLeft(7, ' ') + " "
                        + p.DblValue3.ToString("f2").PadLeft(7, ' ') + " "
                        + p.DblValue4.ToString("f2").PadLeft(7, ' ') + " "
                        + "0".PadLeft(7, ' ') + " "
                        + cmd.PadLeft(7, ' ');
         WriteRobot(value);
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError("LogicRobot", ex);
     }
 }
コード例 #7
0
 //NG
 public void SendDataNG(Point4D p)
 {
     try
     {
         string cmd = NoCamera.ToString() + "9";//命令
         string str = Head
                      + p.DblValue1.ToString("f2").PadLeft(7, ' ') + " "
                      + p.DblValue2.ToString("f2").PadLeft(7, ' ') + " "
                      + p.DblValue3.ToString("f2").PadLeft(7, ' ') + " "
                      + p.DblValue4.ToString("f2").PadLeft(7, ' ') + " "
                      + "0".PadLeft(7, ' ') + " "
                      + cmd.PadLeft(7, ' ');
         g_PortRobotBase.WriteData(str);
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError("LogicRobot", ex);
     }
 }
コード例 #8
0
        public Rgba Luminosity(Point4D location, Vector normal, Light sourceLight)
        {
            switch (sourceLight)
            {
            case SpotLight spotLight:
                return(sourceLight.Rgba * LuminositySpotLight(location, normal, spotLight));

            case PointLight pointLight:
                return(sourceLight.Rgba * LuminosityPointLight(location, normal, pointLight));

            case DirectionLight directionLight:
                return(sourceLight.Rgba * LuminosityDirectionLight(normal, directionLight));

            case AmbientLight ambientLight:
                return(sourceLight.Rgba * LuminosityAmbientLight(ambientLight));
            }

            throw new ArgumentException("Light Type not supported");
        }
コード例 #9
0
        Point3D CalculatePoint(Point3D ptIn, Vector delta, double angle)
        {
            Point4D pt4In  = (Point4D)ptIn;
            Point4D pt4Out = pt4In * matxVisualToScreen;

            rotate.Angle = angle;
            delta        = (Vector)rotate.Transform((Point)delta);

            pt4Out.X += delta.X * pt4Out.W;
            pt4Out.Y += delta.Y * pt4Out.W;

            pt4Out *= matxScreenToVisual;

            Point3D ptOut = new Point3D(pt4Out.X / pt4Out.W,
                                        pt4Out.Y / pt4Out.W,
                                        pt4Out.Z / pt4Out.W);

            return(ptOut);
        }
コード例 #10
0
        /// <summary>
        /// 写入点位
        /// </summary>
        /// <param name="xeRoot"></param>
        /// <param name="robotStdPoint"></param>
        bool WriteMovePoint(XmlElement xeRoot, RobotStdPoint robotStdPoint)
        {
            try
            {
                Point4D p_Move = robotStdPoint.P_Move;

                //vel
                XmlElement xeMove = CreateNewXe(xeRoot, "Move");
                xeRoot.AppendChild(xeMove);

                MoveRobot_enum moveRobot_e = MoveRobot_enum.Stay;
                moveRobot_e = (MoveRobot_enum)p_Move.DblValue1 - 1;
                WriteAttribute(xeMove, "Type", moveRobot_e.ToString());

                //passCMD
                Point4D p_passCMD = robotStdPoint.P_PassCMD;

                XmlElement xePassCMD = CreateNewXe(xeRoot, "PassCMD");
                xeRoot.AppendChild(xePassCMD);

                WriteAttribute(xePassCMD, "Num", p_passCMD.DblValue1.ToString());

                TypePosRobot_enum typeZ_e = (TypePosRobot_enum)p_passCMD.DblValue2 - 1;
                WriteAttribute(xePassCMD, "Z", typeZ_e.ToString());
                TypePosRobot_enum typeR_e = (TypePosRobot_enum)p_passCMD.DblValue3 - 1;
                WriteAttribute(xePassCMD, "R", typeR_e.ToString());

                WriteMovePoint(xeRoot, "Here", robotStdPoint.P_Here);
                WriteMovePoint(xeRoot, "Pass1", robotStdPoint.P_Pass1);
                WriteMovePoint(xeRoot, "Pass2", robotStdPoint.P_Pass2);
                WriteMovePoint(xeRoot, "Pass3", robotStdPoint.P_Pass3);

                //des
                WriteMovePoint(xeRoot, "Des", robotStdPoint.P_Des);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #11
0
        Point4D ReadOutIO(XmlElement xeRoot)
        {
            try
            {
                Point4D point = new Point4D();

                bool enable = ReadChildAttributeBl(xeRoot, "OutIO", "Enable");
                point.DblValue1 = enable ? 1 : -1;

                point.DblValue2 = ReadChildAttributeInt(xeRoot, "OutIO", "IO");
                string annotation = ReadChildAttributeStr(xeRoot, "OutIO", "Annotation");

                point.NameClass = "OutIO";
                return(point);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #12
0
ファイル: Day17.cs プロジェクト: dunder/advent-of-code
 public IEnumerable <(Point4D point, bool value)> Neighbors(Point4D point)
 {
     for (int w = point.W - 1; w <= point.W + 1; w++)
     {
         for (int z = point.Z - 1; z <= point.Z + 1; z++)
         {
             for (int y = point.Y - 1; y <= point.Y + 1; y++)
             {
                 for (int x = point.X - 1; x <= point.X + 1; x++)
                 {
                     var neighbor = new Point4D(x, y, z, w);
                     if (neighbor != point)
                     {
                         yield return(neighbor, Squares.Contains(neighbor));
                     }
                 }
             }
         }
     }
 }
コード例 #13
0
 protected override IEnumerable <Point4D> AdjacentPoints(Point4D point)
 {
     for (var dx = -1; dx <= 1; dx++)
     {
         for (var dy = -1; dy <= 1; dy++)
         {
             for (var dz = -1; dz <= 1; dz++)
             {
                 for (var dw = -1; dw <= 1; dw++)
                 {
                     if (dx == 0 && dy == 0 && dz == 0 && dw == 0)
                     {
                         continue;
                     }
                     yield return(new Point4D(point.X + dx, point.Y + dy, point.Z + dz, point.W + dw));
                 }
             }
         }
     }
 }
コード例 #14
0
        public static void Transform(Matrix3D modelMatrix,
                                     ref Point3D origin, ref Vector3D direction, out bool isRay)
        {
            if (modelMatrix.InvertCore())
            {
                Point4D o = new Point4D(origin.X, origin.Y, origin.Z, 1);
                Point4D d = new Point4D(direction.X, direction.Y, direction.Z, 0);

                modelMatrix.MultiplyPoint(ref o);
                modelMatrix.MultiplyPoint(ref d);

                if (o.W == 1 && d.W == 0)
                {
                    // Affine transformation

                    origin    = new Point3D(o.X, o.Y, o.Z);
                    direction = new Vector3D(d.X, d.Y, d.Z);

                    isRay = true;
                }
                else
                {
                    // Non-affine transformation (likely projection)

                    // Form 4x2 matrix with two points on line in two columns.
                    double[,] linepoints = new double[, ] {
                        { o.X, d.X }, { o.Y, d.Y }, { o.Z, d.Z }, { o.W, d.W }
                    };

                    ColumnsToAffinePointVector(linepoints, 0, 1, out origin, out direction);

                    isRay = false;
                }
            }
            else
            {
                TransformSingular(ref modelMatrix, ref origin, ref direction);

                isRay = false;
            }
        }
コード例 #15
0
ファイル: CodeParser.cs プロジェクト: zhuowp-fork/Shazzam
        /// <summary>
        /// Parses the string representation of an HLSL float, float2, float3, or float4 value,
        /// setting the final parameter to the corresponding double, Point, Point3D, or Color if possible.
        /// </summary>
        private static void ParseInitializerValue(string initializerValueText, Type registerType, ref object initializerValue)
        {
            var numbers = ParseNumbers(initializerValueText);

            if (registerType == typeof(double) && numbers.Length >= 1)
            {
                initializerValue = numbers[0];
            }
            else if (registerType == typeof(float) && numbers.Length >= 1)
            {
                initializerValue = (float)numbers[0];
            }
            else if (registerType == typeof(Point) && numbers.Length >= 2)
            {
                initializerValue = new Point(numbers[0], numbers[1]);
            }
            else if (registerType == typeof(Size) && numbers.Length >= 2)
            {
                initializerValue = new Size(Math.Max(0, numbers[0]), Math.Max(0, numbers[1]));
            }
            else if (registerType == typeof(Vector) && numbers.Length >= 2)
            {
                initializerValue = new Vector(numbers[0], numbers[1]);
            }
            else if (registerType == typeof(Point3D) && numbers.Length >= 3)
            {
                initializerValue = new Point3D(numbers[0], numbers[1], numbers[2]);
            }
            else if (registerType == typeof(Vector3D) && numbers.Length >= 3)
            {
                initializerValue = new Vector3D(numbers[0], numbers[1], numbers[2]);
            }
            else if (registerType == typeof(Point4D) && numbers.Length >= 4)
            {
                initializerValue = new Point4D(numbers[0], numbers[1], numbers[2], numbers[3]);
            }
            else if (registerType == typeof(Color) && numbers.Length >= 4)
            {
                initializerValue = Color.FromArgb(ConvertToByte(numbers[3]), ConvertToByte(numbers[0]), ConvertToByte(numbers[1]), ConvertToByte(numbers[2]));
            }
        }
コード例 #16
0
        private void BtnCtrs_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button  button  = sender as Button;
                string  content = button.Content as string;
                Point4D pCmd    = new Point4D();
                switch (content)
                {
                case "Y↑":
                    pCmd = new Point4D(0, YStep, 0, 0);
                    break;

                case "Y↓":
                    pCmd = new Point4D(0, -YStep, 0, 0);
                    break;

                case "←X":
                    pCmd = new Point4D(-XStep, 0, 0, 0);
                    break;

                case "X→":
                    pCmd = new Point4D(XStep, 0, 0, 0);
                    break;

                case "Z↑":
                    pCmd = new Point4D(0, 0, ZStep, 0);
                    break;

                case "Z↓":
                    pCmd = new Point4D(0, 0, -ZStep, 0);
                    break;
                }
                LogicRobot.L_I.WriteRobotCMD(pCmd, PCToRbt.PRP_Drive);
                EnableDriveButton(false);//使能控件,等待外部信号重新使能
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
コード例 #17
0
        public Form1()
        {
            InitializeComponent();
            pictureBox1.Image = null;
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            pictureBox1.Image = bmp;
            graphics          = pictureBox1.CreateGraphics();
            pen = new Pen(Color.White, 3);
            originalVertices1    = new Point4D[8];
            vertices1            = new Point4D[8];
            originalVertices1[0] = new Point4D(-length / 2, -height, -length / 2, 1);
            originalVertices1[1] = new Point4D(length / 2, -height, -length / 2, 1);
            originalVertices1[2] = new Point4D(length / 2, -height, length / 2, 1);
            originalVertices1[3] = new Point4D(-length / 2, -height, length / 2, 1);
            originalVertices1[4] = new Point4D(-length / 2, height, length / 2, 1);
            originalVertices1[5] = new Point4D(-length / 2, height, -length / 2, 1);
            originalVertices1[6] = new Point4D(length / 2, height, -length / 2, 1);
            originalVertices1[7] = new Point4D(length / 2, height, length / 2, 1);
            faces1 = new face[6];

            originalVertices2    = new Point4D[8];
            vertices2            = new Point4D[8];
            originalVertices2[0] = new Point4D(-length / 2 + difference, -height + difference, -length / 2 + difference, 1);
            originalVertices2[1] = new Point4D(length / 2 + difference, -height + difference, -length / 2 + difference, 1);
            originalVertices2[2] = new Point4D(length / 2 + difference, -height + difference, length / 2 + difference, 1);
            originalVertices2[3] = new Point4D(-length / 2 + difference, -height + difference, length / 2 + difference, 1);
            originalVertices2[4] = new Point4D(-length / 2 + difference, height + difference, length / 2 + difference, 1);
            originalVertices2[5] = new Point4D(-length / 2 + difference, height + difference, -length / 2 + difference, 1);
            originalVertices2[6] = new Point4D(length / 2 + difference, height + difference, -length / 2 + difference, 1);
            originalVertices2[7] = new Point4D(length / 2 + difference, height + difference, length / 2 + difference, 1);
            faces2 = new face[6];

            zBuffer = new float[pictureBox1.Width, pictureBox1.Height];

            colors1 = new Color[6] {
                Color.Peru, Color.Sienna, Color.Gray, Color.Moccasin, Color.Tan, Color.Maroon
            };
            colors2 = new Color[6] {
                Color.Moccasin, Color.Tan, Color.Maroon, Color.Peru, Color.Sienna, Color.Gray
            };
        }
コード例 #18
0
        private static Ray3D RayFromMatrixCameraPoint(MatrixCamera camera, Point point, Size viewSize)
        {
            Point    normalizedPoint = CameraRayHelpers.GetNormalizedPoint(point, viewSize);
            Matrix3D matrix3D        = camera.ViewMatrix * camera.ProjectionMatrix;

            if (!matrix3D.HasInverse)
            {
                throw new NotSupportedException(ExceptionStringTable.NeedToHandleSingularMatrixCameras);
            }
            matrix3D.Invert();
            Point4D  point4D   = new Point4D(normalizedPoint.X, normalizedPoint.Y, 0.0, 1.0) * matrix3D;
            Point3D  origin    = new Point3D(point4D.X / point4D.W, point4D.Y / point4D.W, point4D.Z / point4D.W);
            Vector3D direction = new Vector3D(matrix3D.M31 - matrix3D.M34 * origin.X, matrix3D.M32 - matrix3D.M34 * origin.Y, matrix3D.M33 - matrix3D.M34 * origin.Z);

            direction.Normalize();
            if (point4D.W < 0.0)
            {
                direction = -direction;
            }
            return(new Ray3D(origin, direction));
        }
コード例 #19
0
        public void AssembleFieldInfo(out Point4D bounds, out List <double> zs, out List <List <Point3D> > functions, out List <string> fct_names)
        {
            if (this.tables == null || this.tables.Count < 1)
            {
                bounds    = this.Bounds;
                zs        = new List <double>();
                functions = new List <List <Point3D> >();
                fct_names = new List <string>();
                return;
            }

            bounds    = this.Bounds;
            zs        = this.ExtractZValues();
            functions = new List <List <Point3D> >();
            fct_names = new List <string>();
            for (int i = 0; i < this.tables.Count; i++)
            {
                functions.AddRange(this.tables[i].FunctionGraphs);
                fct_names.AddRange(this.tables[i].FunctionNames);
            }
        }
コード例 #20
0
        public GeometricRelationship(string _name, Relation2GeomState _state, Point4D _ids, Matrix3D _cs, Matrix3D _tr_WC2LC, Matrix3D _tr_LC2WC)
        {
            // general
            this.ID        = (++GeometricRelationship.NR_GEOMETRICRELATIONSHIPS);
            this.Name      = (string.IsNullOrEmpty(_name)) ? "Geometry" : _name;
            this.State     = _state;
            this.GeomIDs   = _ids;
            this.GeomCS    = _cs;
            this.TRm_WC2LC = _tr_WC2LC;
            this.TRm_LC2WC = _tr_LC2WC;

            // instance information
            this.instance_size = new List <double>();
            this.instance_size_transfer_settings = new List <GeomSizeTransferDef>();
            this.instance_nwe_id     = -1L;
            this.instance_nwe_name   = "NW_Element";
            this.InstancePath        = new List <Point3D>();
            this.InstanceParamValues = new Dictionary <string, double>(); // transient!

            this.UpdateState = GeometricRelationshipUpdateState.NEUTRAL;
        }
コード例 #21
0
        bool WritePar4(Point4D point, int index)
        {
            try
            {
                string value = Head
                               + point.DblValue1.ToString().PadLeft(7, ' ') + " "
                               + point.DblValue2.ToString().PadLeft(7, ' ') + " "
                               + point.DblValue3.ToString().PadLeft(7, ' ') + " "
                               + point.DblValue4.ToString().PadLeft(7, ' ') + " "
                               + "0.0".PadLeft(7, ' ') + " "
                               + ParLogicRobot.c_CmdPar4 + index.ToString().PadLeft(7, ' ');

                WriteRobot(value);
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError("LogicRobot", ex);
                return(false);
            }
        }
コード例 #22
0
        /// <summary>
        /// 精定位偏差计算
        /// </summary>
        /// <param name="r">第一次定位取得的角度</param>
        /// <param name="delta">像素偏差</param>
        /// <returns></returns>
        private bool BolbDevationCalc(double r, Point2D delta, out Point2D pDelta)
        {
            //根据配方,选择平台放片目标点
            Point4D dst = ModelParams.confWastagePlatStation == 1 ? ModelParams.PosWastagePlat1 : ModelParams.PosWastagePlat2;

            return(BackLightLocation.BolbDevationCalc(dst,
                                                      delta,
                                                      ModelParams.PreciseRobotAngle,
                                                      ModelParams.BotWastageAngle,
                                                      r,
                                                      ModelParams.cmd_PreciseResult,
                                                      ModelParams.cmd_PreciseFailed,
                                                      ModelParams.PreciseThreadX,
                                                      ModelParams.PreciseThreadY,
                                                      ModelParams.BotPlaceAngle,
                                                      ModelParams.DisplayAngle,
                                                      ModelParams.BLPlaceAngle,
                                                      RegeditMain.R_I.ID,
                                                      ModelParams.IfRecordData,
                                                      out pDelta));
        }
コード例 #23
0
        protected void CreatePositions(double depthOffset = 0.0)
        {
            double halfSize  = this.Size / 2.0;
            int    numPoints = this.Points.Length;

            Vector[] outline = new Vector[]
            {
                new Vector(-halfSize, halfSize),
                new Vector(-halfSize, -halfSize),
                new Vector(halfSize, halfSize),
                new Vector(halfSize, -halfSize)
            };
            Point3DCollection positions = new Point3DCollection(numPoints * 4);

            for (int x = 0; x < this.Points.GetLength(0); x++)
            {
                for (int y = 0; y < this.Points.GetLength(1); y++)
                {
                    Point4D screenPoint = (Point4D)this.Points[x, y] * _visualToScreen;
                    double  spx         = screenPoint.X;
                    double  spy         = screenPoint.Y;
                    double  spz         = screenPoint.Z;
                    double  spw         = screenPoint.W;
                    if (!depthOffset.Equals(0.0))
                    {
                        spz -= depthOffset * spw;
                    }
                    double   pwinverse = 1.0 / (new Point4D(spx, spy, spz, spw) * _screenToVisual).W;
                    Vector[] array     = outline;
                    for (int i = 0; i < array.Length; i++)
                    {
                        Vector  v = array[i];
                        Point4D p = new Point4D(spx + v.X * spw, spy + v.Y * spw, spz, spw) * _screenToVisual;
                        positions.Add(new Point3D(p.X * pwinverse, p.Y * pwinverse, p.Z * pwinverse));
                    }
                }
            }
            positions.Freeze();
            _mesh.Positions = positions;
        }
コード例 #24
0
        /// <summary>
        /// Creates the positions for the specified points.
        /// </summary>
        /// <param name="points">
        /// The points.
        /// </param>
        /// <param name="size">
        /// The size of the points.
        /// </param>
        /// <param name="depthOffset">
        /// The depth offset. A positive number (e.g. 0.0001) moves the point towards the camera.
        /// </param>
        /// <returns>
        /// The positions collection.
        /// </returns>
        public Point3DCollection CreatePositions(IList <Point3D> points, double size = 1.0, double depthOffset = 0.0)
        {
            double halfSize  = size / 2.0;
            int    numPoints = points.Count;

            var outline = new[]
            {
                new Vector(-halfSize, halfSize), new Vector(-halfSize, -halfSize), new Vector(halfSize, halfSize),
                new Vector(halfSize, -halfSize)
            };

            var positions = new Point3DCollection(numPoints * 4);

            for (int i = 0; i < numPoints; i++)
            {
                var screenPoint = (Point4D)points[i] * this.visualToScreen;

                double spx = screenPoint.X;
                double spy = screenPoint.Y;
                double spz = screenPoint.Z;
                double spw = screenPoint.W;

                if (!depthOffset.Equals(0))
                {
                    spz -= depthOffset * spw;
                }

                var    p0        = new Point4D(spx, spy, spz, spw) * this.screenToVisual;
                double pwinverse = 1 / p0.W;

                foreach (var v in outline)
                {
                    var p = new Point4D(spx + v.X * spw, spy + v.Y * spw, spz, spw) * this.screenToVisual;
                    positions.Add(new Point3D(p.X * pwinverse, p.Y * pwinverse, p.Z * pwinverse));
                }
            }

            positions.Freeze();
            return(positions);
        }
コード例 #25
0
        public void SetAxisValues(TableAxisValues _input_axis, Point4D _input_bounds)
        {
            //// debug
            //var id = this.id;
            //double y0 = (this.ys != null && this.ys.Count > 0) ? this.ys[0] : double.MinValue;
            //double y0_in = (_input_axis.Ys.Count > 0) ? _input_axis.Ys[0] : double.MinValue;
            //// debug

            if (this.xs != null && this.ys != null)
            {
                return;
            }
            if (_input_axis.Xs.Count < 1 || _input_axis.Ys.Count < 1)
            {
                return;
            }

            this.bounds = _input_bounds;
            this.xs     = new List <double>(_input_axis.Xs);
            this.ys     = new List <double>(_input_axis.Ys);
            this.UpdateInfoCells();
        }
コード例 #26
0
        public string CanvasConnectionInfo()
        {
            string children_str = string.Empty;

            foreach (object child in this.Children)
            {
                if (child is Line || child is TextBlock)
                {
                    continue;
                }

                Polyline pl = child as Polyline;
                if (pl != null)
                {
                    if (pl.Tag == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (pl.Tag is Point4D)
                        {
                            Point4D p = (Point4D)pl.Tag;
                            children_str += "Polyline: start(" + p.X.ToString("F2", CompGraph.FORMATTER) + ", " +
                                            p.Y.ToString("F2", CompGraph.FORMATTER) + ") " +
                                            "end(" +
                                            p.Z.ToString("F2", CompGraph.FORMATTER) + ", " +
                                            p.W.ToString("F2", CompGraph.FORMATTER) + ")\n";
                        }
                    }
                }
                else
                {
                    children_str += child.ToString() + "\n";
                }
            }

            return(children_str);
        }
コード例 #27
0
        /// <summary>
        /// 计算机器人取片坐标,纯计算不带信息输出
        /// </summary>
        /// <param name="pt2Pixel">粗定位相机的像素结果</param>
        /// <param name="pt4Dst">机器人取片基准值</param>
        /// <param name="pt4Adj">机器人取片补偿</param>
        /// <param name="parCalibrate">机器人校准算子参数</param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool CalcRobotPickPos(Point2D pt2Pixel, Point4D pt4Dst, Point4D pt4Adj,
                                            BaseParCalibRobot parCalibrate, out Point4D result)
        {
            result = pt4Dst + pt4Adj;
            try
            {
                Point2D pt2Map = FunCalibRobot.F_I.GetWordCord(pt2Pixel, parCalibrate);
                if (pt2Map.DblValue1 * pt2Map.DblValue2 == 0)
                {
                    return(false);
                }
                result = new Point4D(pt2Map.DblValue1 + pt4Adj.DblValue1, pt2Map.DblValue2 +
                                     pt4Adj.DblValue2, pt4Dst.DblValue3 + pt4Adj.DblValue3, pt4Dst.DblValue4 + pt4Adj.DblValue4);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(ClassName, ex);
                return(false);
            }

            return(true);
        }
コード例 #28
0
        public void WriteStdData(int noPos, Point4D point)
        {
            try
            {
                string cmd = NoCamera.ToString() + "1";//命令

                string value = "PData".PadLeft(7, ' ') + " "
                               + noPos.ToString().PadLeft(7, ' ') + " "
                               + point.DblValue1.ToString("f2").PadLeft(7, ' ') + " "
                               + point.DblValue2.ToString("f2").PadLeft(7, ' ') + " "
                               + point.DblValue3.ToString("f2").PadLeft(7, ' ') + " "
                               + point.DblValue4.ToString("f2").PadLeft(7, ' ') + " "
                               + "0".PadLeft(7, ' ') + " "
                               + "0".PadLeft(7, ' ');

                WriteRobot(value);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError("LogicRobot", ex);
            }
        }
コード例 #29
0
        /// <summary>
        /// 背光,不规则区域,偏差计算
        /// </summary>
        /// <param name="dst">目标点bot基准坐标</param>
        /// <param name="delta">画面实际偏差(mm)</param>
        /// <param name="srcAngle">当前位置机器人角度</param>
        /// <param name="dstAngle">目标点机器人角度</param>
        /// <param name="r">第一次拍照获得的角度偏差</param>
        /// <param name="cmdOK">与bot协议,表示偏差计算ok</param>
        /// <param name="cmdError">与bot协议,表示偏差计算失败</param>
        /// <param name="threadX">偏差阈值X</param>
        /// <param name="threadY">偏差阈值Y</param>
        /// <param name="botAngle">机器人放置角度,</param>
        /// <param name="displayAngle">画面角度</param>
        /// <param name="blAngle">背光放置角度</param>
        /// <param name="id"></param>
        /// <param name="ifRecord"></param>
        /// <returns></returns>
        public static bool BolbDevationCalc(Point4D dst, Point2D delta, double srcAngle,
                                            double dstAngle, double r, string cmdOK, string cmdError, double threadX, double threadY,
                                            double botAngle, double displayAngle, double blAngle, int id, bool ifRecord, out Point2D deltaDst)
        {
            deltaDst = new Point2D();
            try
            {
                deltaDst = GetDeviationForBot(delta, botAngle, displayAngle, blAngle, srcAngle, dstAngle);
                ShowState(string.Format("精定位偏差X:{0},Y{1}",
                                        deltaDst.DblValue1.ToString("f3"),
                                        deltaDst.DblValue2.ToString(ReservDigits)));

                if (deltaDst.DblValue1 > threadX || deltaDst.DblValue2 > threadY)
                {
                    ShowAlarm(string.Format("精定位偏差超出阈值[{0},{1}]", threadX, threadY));
                    LogicRobot.L_I.WriteRobotCMD(cmdError);
                    return(false);
                }

                Point4D pt4Dst = new Point4D(deltaDst.DblValue1, deltaDst.DblValue2, 0, r) + dst;
                LogicRobot.L_I.WriteRobotCMD(pt4Dst, cmdOK);
                ShowState(string.Format("发送放片坐标:X:{0},Y:{1},R:{2}",
                                        pt4Dst.DblValue1.ToString(ReservDigits),
                                        pt4Dst.DblValue2.ToString(ReservDigits),
                                        pt4Dst.DblValue4.ToString(ReservDigits)));

                if (ifRecord)
                {
                    RecordPreciseData(id, "第二次精定位结果:X-->" + deltaDst.DblValue1.ToString(ReservDigits) +
                                      " Y-->" + deltaDst.DblValue2.ToString(ReservDigits) + " R-->" + r.ToString(ReservDigits));
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(ClassName, ex);
                return(false);
            }
        }
コード例 #30
0
        /// <summary>
        /// 真空
        /// </summary>
        /// <param name="xeRoot"></param>
        /// <param name="point"></param>
        bool WriteVaccum(XmlElement xeRoot, RobotStdPoint robotStdPoint)
        {
            try
            {
                XmlElement xeVaccum = CreateNewXe(xeRoot, "Vaccum");
                xeRoot.AppendChild(xeVaccum);

                Point4D point  = robotStdPoint.P_Vaccum;
                bool    enable = point.DblValue1 == -1 ? false : true;

                WriteAttribute(xeVaccum, "Enable", enable.ToString());
                WriteAttribute(xeVaccum, "NoIO", point.DblValue1.ToString());
                WriteAttribute(xeVaccum, "WaitTime", point.DblValue2.ToString());
                WriteAttribute(xeVaccum, "NGIO", point.DblValue3.ToString());
                WriteAttribute(xeVaccum, "NGPos", point.DblValue4.ToString());
                WriteAttribute(xeVaccum, "Annotation", point.Annotation.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #31
0
        private static IEnumerable <Point4D> HyperNeighbours(Point4D point, bool includeMySelf = false)
        {
            var rc = new HashSet <Point4D>();

            for (var x = point.X - 1; x <= point.X + 1; x++)
            {
                for (var y = point.Y - 1; y <= point.Y + 1; y++)
                {
                    for (var z = point.Z - 1; z <= point.Z + 1; z++)
                    {
                        for (var t = point.T - 1; t <= point.T + 1; t++)
                        {
                            rc.Add(new Point4D(x, y, z, t));
                        }
                    }
                }
            }
            if (!includeMySelf)
            {
                rc.Remove(point);
            }
            return(rc);
        }
コード例 #32
0
 public void ToStringTest()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D ); // TODO: 初始化为适当的值
     string expected = string.Empty; // TODO: 初始化为适当的值
     string actual;
     actual = target.ToString();
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
コード例 #33
0
 public void GetHashCodeTest()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D ); // TODO: 初始化为适当的值
     int expected = 0; // TODO: 初始化为适当的值
     int actual;
     actual = target.GetHashCode();
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
コード例 #34
0
 public void EqualsTest()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D ); // TODO: 初始化为适当的值
     object xObject = null; // TODO: 初始化为适当的值
     bool expected = false; // TODO: 初始化为适当的值
     bool actual;
     actual = target.Equals( xObject );
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
コード例 #35
0
 public void CompareToTest()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D ); // TODO: 初始化为适当的值
     object other = null; // TODO: 初始化为适当的值
     int expected = 0; // TODO: 初始化为适当的值
     int actual;
     actual = target.CompareTo( other );
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
コード例 #36
0
 public void Point4DConstructorTest3()
 {
     IPoint4D point4D = null; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point4D );
     Assert.Inconclusive( "TODO: 实现用来验证目标的代码" );
 }
コード例 #37
0
 public void Point4DConstructorTest2()
 {
     float x = 0F; // TODO: 初始化为适当的值
     float y = 0F; // TODO: 初始化为适当的值
     float z = 0F; // TODO: 初始化为适当的值
     float orientation = 0F; // TODO: 初始化为适当的值
     Point4D target = new Point4D( x, y, z, orientation );
     Assert.Inconclusive( "TODO: 实现用来验证目标的代码" );
 }
コード例 #38
0
 public void Point4DConstructorTest()
 {
     IPoint3D point3D = null; // TODO: 初始化为适当的值
     float orientation = 0F; // TODO: 初始化为适当的值
     Point4D target = new Point4D( point3D, orientation );
     Assert.Inconclusive( "TODO: 实现用来验证目标的代码" );
 }
コード例 #39
0
ファイル: Transform3D.cs プロジェクト: tgjones/nexus
 public void Transform(Point4D[] points)
 {
     Value.Transform(points);
 }
コード例 #40
0
ファイル: Transform3D.cs プロジェクト: tgjones/nexus
 public Point4D Transform(Point4D point)
 {
     return Value.Transform(point);
 }