示例#1
0
        private void DrawLine(Graphics g, int xFrom, int yFrom, int size, LineMode lm)
        {
            Pen pen1 = null;
            Pen pen2 = null;

            if (lm == LineMode.Normal)
            {
                pen1 = m_penGray;
                pen2 = m_penWhite;
            }
            else
            {
                pen1 = m_penWhite;
                pen2 = m_penGray;
            }

            if (Orientation == Orientation.Horizontal)
            {
                g.DrawLine(pen1, new Point(xFrom, yFrom), new Point(xFrom + size, yFrom));
                g.DrawLine(pen2, new Point(xFrom, yFrom + 1), new Point(xFrom + size, yFrom + 1));
            }
            else
            {
                g.DrawLine(pen1, new Point(xFrom, yFrom), new Point(xFrom, yFrom + size));
                g.DrawLine(pen2, new Point(xFrom + 1, yFrom), new Point(xFrom + 1, yFrom + size));
            }
        }
示例#2
0
        /// <summary>
        /// Calculates distance between a point and a great circle path connecting points A and B.
        /// </summary>
        /// <param name="c">The coordinate to compute the distance for.</param>
        /// <param name="a">The first point of the great circle.</param>
        /// <param name="b">The second point of the great circle.</param>
        /// <param name="mode">LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B.</param>
        /// <returns> The distance from c to great circle connecting points AB in units of the <see cref="Sphere2DCalculator.Radius"/> property.</returns>
        public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            double bearingAB = this.CalculateBearing(a, b);
            double bearingAC = this.CalculateBearing(a, c);

            double distAC = this.CalculateDistance(a, c);

            //Sign can be used to determine if point is left/right of the great circle
            double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius);

            if (mode == LineMode.Line)
            {
                return(distCircleC);
            }
            else
            {
                double bearingBA = this.CalculateBearing(b, a);
                double bearingBC = this.CalculateBearing(b, c);

                if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2)
                {
                    return(distAC);
                }
                else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2)
                {
                    return(this.CalculateDistance(b, c));
                }
                else
                {
                    return(distCircleC);
                }
            }
        }
        public PlotViewModel(LineMode mode, int dataPointsCount, Axis yAxis)
        {
            Mode = mode;
            DataPointsCount = dataPointsCount;
            _series = new Dictionary<string, LineSeries>();
            _lastPointOfSeries = new Dictionary<string, DataPoint>();

            LinearAxis xAxis = new LinearAxis();
            xAxis.Position = AxisPosition.Bottom;
            xAxis.Title = "Time";

            yAxis.Position = AxisPosition.Left;
            yAxis.Title = "Values";

            var plot = new PlotModel
            {
                Title = Title,
                TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinPlotArea,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement = LegendPlacement.Outside,
                LegendPosition = LegendPosition.TopCenter
            };

            plot.Axes.Add(xAxis);
            plot.Axes.Add(yAxis);

            Plot = plot;
        }
 protected AppearanceBase()
 {
     this.m_layer           = 0;
     this.m_lineMode        = (LineMode)null;
     this.m_polygonMode     = (PolygonMode)null;
     this.m_compositingMode = (CompositingMode)null;
 }
        /// <summary>
        /// Determines whether two lines or line segments intersects
        /// </summary>
        /// <param name="a1">The first point of the first line</param>
        /// <param name="b1">The second point of the first line</param>
        /// <param name="line1Mode">LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment</param>
        /// <param name="a2">The first point of the second line</param>
        /// <param name="b2">The second point of the second line</param>
        /// <param name="line2Mode">LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment</param>
        /// <returns>true if A1B1 intersects A2B2, otherwise returns false</returns>
        public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode)
        {
            double paramA1 = b1.Y - a1.Y;
            double paramB1 = a1.X - b1.X;
            double paramC1 = paramA1 * a1.X + paramB1 * a1.Y;

            double paramA2 = b2.Y - a2.Y;
            double paramB2 = a2.X - b2.X;
            double paramC2 = paramA2 * a2.X + paramB2 * a2.Y;

            double det = paramA1 * paramB2 - paramA2 * paramB1;
            if (det == 0) {
                return false;
            }
            else {
                double x = (paramB2 * paramC1 - paramB1 * paramC2) / det;
                double y = (paramA1 * paramC2 - paramA2 * paramC1) / det;

                if (line1Mode == LineMode.LineSegment) {
                    if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y)) {
                        return false;
                    }
                }

                if (line2Mode == LineMode.LineSegment) {
                    if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y)) {
                        return false;
                    }
                }

                return true;
            }
        }
示例#6
0
        public static void Bounds(Bounds bounds, Matrix4x4 matrix, LineMode mode)
        {
            var leftTopFront     = matrix.MultiplyPoint3x4(bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, bounds.extents.z));
            var rightTopFront    = matrix.MultiplyPoint3x4(bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z));
            var leftBottomFront  = matrix.MultiplyPoint3x4(bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, bounds.extents.z));
            var rightBottomFront = matrix.MultiplyPoint3x4(bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, bounds.extents.z));
            var leftTopBack      = matrix.MultiplyPoint3x4(bounds.center + new Vector3(-bounds.extents.x, bounds.extents.y, -bounds.extents.z));
            var rightTopBack     = matrix.MultiplyPoint3x4(bounds.center + new Vector3(bounds.extents.x, bounds.extents.y, -bounds.extents.z));
            var leftBottomBack   = matrix.MultiplyPoint3x4(bounds.center + new Vector3(-bounds.extents.x, -bounds.extents.y, -bounds.extents.z));
            var rightBottomBack  = matrix.MultiplyPoint3x4(bounds.center + new Vector3(bounds.extents.x, -bounds.extents.y, -bounds.extents.z));

            // Front
            Line(leftTopFront, rightTopFront, mode);
            Line(rightTopFront, rightBottomFront, mode);
            Line(rightBottomFront, leftBottomFront, mode);
            Line(leftBottomFront, leftTopFront, mode);
            // Back
            Line(leftTopBack, rightTopBack, mode);
            Line(rightTopBack, rightBottomBack, mode);
            Line(rightBottomBack, leftBottomBack, mode);
            Line(leftBottomBack, leftTopBack, mode);
            // Side
            Line(leftTopBack, leftTopFront, mode);
            Line(rightTopBack, rightTopFront, mode);
            Line(rightBottomBack, rightBottomFront, mode);
            Line(leftBottomBack, leftBottomFront, mode);
        }
示例#7
0
        public override bool Read(GH_IReader reader)
        {
            int num = 2;

            reader.TryGetInt32("LineMode", ref num);
            this.lineMode = (LineMode)num;
            return(base.Read(reader));
        }
示例#8
0
 public Series(string name, Color color, LineMode lineMode, LineStyle lineStyle)
 {
     this.name      = name;
     this.color     = new SKColor(color.R, color.G, color.B, color.A);
     this.lineMode  = lineMode;
     this.lineStyle = lineStyle;
     this.visible   = true;
 }
示例#9
0
 public SeparatorControl()
 {
     TabStop      = false;
     m_lineLength = 40;
     m_lineMode   = LineMode.down;
     m_penGray    = new Pen(SystemColors.ControlDark, 1);
     m_penWhite   = new Pen(Color.White, 1);
 }
示例#10
0
 private void Menu_ModelClicked(object sender, EventArgs e)
 {
     if (this.lineMode != LineMode.ModelLine)
     {
         this.RecordUndoEvent("Model Line");
         this.lineMode = LineMode.ModelLine;
         this.ExpireSolution(true);
     }
 }
示例#11
0
 private void Menu_RoomClicked(object sender, EventArgs e)
 {
     if (this.lineMode != LineMode.RoomSepLine)
     {
         this.RecordUndoEvent("Room Separation Line");
         this.lineMode = LineMode.RoomSepLine;
         this.ExpireSolution(true);
     }
 }
示例#12
0
        static void DrawOutline(CSGCapsuleDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            //var baseColor		= UnityEditor.Handles.yAxisColor;
            //var isDisabled	= UnitySceneExtensions.Handles.disabled;
            //var normal		= Vector3.up;
            var sides = definition.sides;

            // TODO: share this logic with GenerateCapsuleVertices

            var topHemisphere    = definition.haveRoundedTop;
            var bottomHemisphere = definition.haveRoundedBottom;
            var topSegments      = topHemisphere    ? definition.topSegments    : 0;
            var bottomSegments   = bottomHemisphere ? definition.bottomSegments : 0;

            var extraVertices = definition.extraVertexCount;
            var bottomVertex  = definition.bottomVertex;
            var topVertex     = definition.topVertex;

            var rings      = definition.ringCount;
            var bottomRing = (bottomHemisphere) ? (rings - bottomSegments) : rings - 1;
            var topRing    = (topHemisphere) ? (topSegments - 1) : 0;

            var prevColor = UnityEditor.Handles.color;
            var color     = prevColor;

            color.a *= 0.6f;

            for (int i = 0, j = extraVertices; i < rings; i++, j += sides)
            {
                if ((!definition.haveRoundedTop && i == topRing) ||
                    (!definition.haveRoundedBottom && i == bottomRing))
                {
                    continue;
                }
                bool isCapRing = (i == topRing || i == bottomRing);
                UnityEditor.Handles.color = (isCapRing ? prevColor : color);
                CSGOutlineRenderer.DrawLineLoop(vertices, j, sides, lineMode: lineMode, thickness: (isCapRing ? kCapLineThickness : kHorzLineThickness), dashSize: (isCapRing ? 0 : kLineDash));
            }

            UnityEditor.Handles.color = color;
            for (int k = 0; k < sides; k++)
            {
                if (topHemisphere)
                {
                    CSGOutlineRenderer.DrawLine(vertices[topVertex], vertices[extraVertices + k], lineMode: lineMode, thickness: kVertLineThickness);
                }
                for (int i = 0, j = extraVertices; i < rings - 1; i++, j += sides)
                {
                    CSGOutlineRenderer.DrawLine(vertices[j + k], vertices[j + k + sides], lineMode: lineMode, thickness: kVertLineThickness);
                }
                if (bottomHemisphere)
                {
                    CSGOutlineRenderer.DrawLine(vertices[bottomVertex], vertices[extraVertices + k + ((rings - 1) * sides)], lineMode: lineMode, thickness: kVertLineThickness);
                }
            }
            UnityEditor.Handles.color = prevColor;
        }
示例#13
0
 private void Menu_AreaClicked(object sender, EventArgs e)
 {
     if (this.lineMode != LineMode.AreaBoundLine)
     {
         this.RecordUndoEvent("Area Boundary Line");
         this.lineMode = LineMode.AreaBoundLine;
         this.ExpireSolution(true);
     }
 }
示例#14
0
        public void Show(bool doShow, LineMode mode = LineMode.SINGLE)
        {
            lineMode = mode;
            // NOTE: Show() can be called before Start(), and line may not has been GetComponent<>'d yet.
            if (line != null)
            {
                line.enabled = (mode == LineMode.DOUBLE); // hide line when doing one hand manipulation
            }

            gameObject.SetActive(doShow);
        }
示例#15
0
        /// <summary>
        /// Determines whether specific coordinate is on the line defined by two points.
        /// </summary>
        /// <param name="c">The coordinate to be tested</param>
        /// <param name="a">The first point of the line.</param>
        /// <param name="b">The second point of the line.</param>
        /// <param name="mode">LineMode value that specifies whether AB should be treated as infinite line or as line segment</param>
        /// <returns>true if coordinate C is on line AB, otherwise false</returns>
        public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            /*
             *              Express line in analytic form
             *                              paramA * x  +  paramB * y  +  paramC  =  0
             */

            double paramA = b.Y - a.Y;
            double paramB = a.X - b.X;
            double paramC = b.X * a.Y - a.X * b.Y;

            /*
             *              induct coordinate C into equation of the line - if equation
             *                              paramA * c.X + paramB * c.Y + paramC = 0
             *              is valid, point lies on the line
             */

            double cLineResult = paramA * c.X + paramB * c.Y + paramC;

            if (cLineResult != 0.0)
            {
                return(false);
            }

            if (mode == LineMode.Line)
            {
                return(true);
            }

            // compute distance of the C along vector AB
            double r;
            double dx = Math.Abs(b.X - a.X);
            double dy = Math.Abs(b.Y - a.Y);

            if (dx > dy)
            {
                r = (c.X - a.X) / (b.X - a.X);
            }
            else
            {
                r = (c.Y - a.Y) / (b.Y - a.Y);
            }

            if (r < 0.0 || r > 1.0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#16
0
        public void ToggleMode()
        {
            switch (fMode)
            {
            case LineMode.Circles:
                fMode = LineMode.Tree;
                break;

            case LineMode.Tree:
                fMode = LineMode.Circles;
                break;
            }
        }
示例#17
0
        public void ChangeLineModeField(object sender, MouseEventArgs e)
        {
            if (CursorLineMode == LineMode.Horizontal)
            {
                CursorLineMode = LineMode.Vertical;
            }
            else
            {
                CursorLineMode = LineMode.Horizontal;
            }

            CursorPosition.SetPosition(e);
            CursorWrite(CursorPosition.X, CursorPosition.Y);
        }
示例#18
0
        private static Color GetLineColor(LineMode mode)
        {
            switch (mode)
            {
            default:
            case LineMode.Solid:
            case LineMode.SolidDotted:
                return(DeformEditorSettings.SolidHandleColor);

            case LineMode.Light:
            case LineMode.LightDotted:
                return(DeformEditorSettings.LightHandleColor);
            }
        }
示例#19
0
        private static LineMethod GetLineMethod(LineMode mode)
        {
            switch (mode)
            {
            default:
            case LineMode.Solid:
            case LineMode.Light:
                return(Handles.DrawLine);

            case LineMode.SolidDotted:
            case LineMode.LightDotted:
                return((a, b) => Handles.DrawDottedLine(a, b, DeformEditorSettings.DottedLineSize));
            }
        }
示例#20
0
        /// <summary>
        /// 对一个字符添加下划线,其中 mode 表示是词的开始(0)、中间(1)、结束(2)
        /// </summary>
        /// <param name="index"></param>
        /// <param name="mode"></param>
        private void AddLine_OneChar(List <LineInfo> lineInfos, int index, LineMode mode, Color color, int len)
        {
            try
            {
                SizeF size = _charSize;
                Point pt   = _rich.GetPositionFromCharIndex(index); //当前字的位置
                if (pt.X < 0 || pt.Y < 0 || (pt.Y + size.Height) > _rich.Height)
                {
                    //位置不完整的不予显示
                    return;
                }

                int left, top, width;

                left  = pt.X;
                top   = pt.Y + (int)size.Height + 1;
                width = Math.Min((int)size.Width, _rich.ClientRectangle.Width - left);


                //以下是示例,可以对开始、截止不同的地方给断点
                int space = width / 5;
                if (mode == LineMode.Start)
                {
                    left  += space;
                    width -= space;
                }
                else if (mode == LineMode.End)
                {
                    left  -= space;
                    width -= space;
                }
                else if (mode == LineMode.Single)
                {
                    left  += space;
                    width -= space * 2;
                }

                LineInfo line = new LineInfo();
                line.index = index;
                line.color = color;
                line.width = width;
                line.top   = top;
                line.left  = left;
                line.len   = len;
                lineInfos.Add(line);
            }
            catch
            {
            }
        }
        // Base stop drawing method
        protected override void StopDrawing()
        {
            base.StopDrawing();
            LastDrawnObjects.Push(_currentLineRenderer.gameObject);
            switch (Mode)
            {
            case LineMode.FreeHand:
                FreeHandDraw(false);
                break;

            case LineMode.Straight:
                _positions.RemoveAt(_positions.Count - 1);
                SetPositions();
                break;
            }
            _positions.Clear();
            Mode = LineMode.None;
        }
示例#22
0
    void Start()
    {
        Device                = GetComponent <SpriteRenderer>();
        Device.enabled        = false;
        collider              = GetComponent <BoxCollider2D>();
        line                  = GetComponent <LineRenderer>();
        line.sortingLayerName = "Foreground";
        line.sortingOrder     = 0;
        objects               = GameObject.FindGameObjectsWithTag("cuttableLevel");
        removed               = new GameObject[0];
        array                 = new Vector3[2];

        RECALL_MODE = GameManager.Instance.RECALL_MODE;
        LINE_MODE   = GameManager.Instance.LINE_MODE;

        draw       = false;
        didCut     = false;
        reverseCut = 1;
    }
示例#23
0
        static void DrawOutline(CSGTorusDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            //var baseColor		= UnityEditor.Handles.yAxisColor;
            //var isDisabled		= UnitySceneExtensions.Handles.disabled;
            var normal = Vector3.up;

            var horzSegments = definition.horizontalSegments;
            var vertSegments = definition.verticalSegments;

            if (definition.totalAngle != 360)
            {
                horzSegments++;
            }

            var prevColor = UnityEditor.Handles.color;

            prevColor.a *= 0.8f;
            var color = prevColor;

            color.a *= 0.6f;

            UnityEditor.Handles.color = color;
            for (int i = 0, j = 0; i < horzSegments; i++, j += vertSegments)
            {
                CSGOutlineRenderer.DrawLineLoop(vertices, j, vertSegments, lineMode: lineMode, thickness: kVertLineThickness);
            }

            for (int k = 0; k < vertSegments; k++)
            {
                for (int i = 0, j = 0; i < horzSegments - 1; i++, j += vertSegments)
                {
                    CSGOutlineRenderer.DrawLine(vertices[j + k], vertices[j + k + vertSegments], lineMode: lineMode, thickness: kHorzLineThickness);
                }
            }
            if (definition.totalAngle == 360)
            {
                for (int k = 0; k < vertSegments; k++)
                {
                    CSGOutlineRenderer.DrawLine(vertices[k], vertices[k + ((horzSegments - 1) * vertSegments)], lineMode: lineMode, thickness: kHorzLineThickness);
                }
            }
            UnityEditor.Handles.color = prevColor;
        }
示例#24
0
        private void SetLineMode(LineMode line, byte mode)
        {
            _c.SendCommand("LM", (int)line, mode);

            switch (line)
            {
            case LineMode.TrackColor:
                _stateLineModeTrack = mode;
                break;

            case LineMode.Mean:
                _stateLineModeMean = mode;
                break;

            case LineMode.Differencing:
                _stateLineModeDiff = mode;
                break;
            }
        }
示例#25
0
        public DrawLine(Point startPoint, Point endPoint, LineMode mode)
        {
            //Start und Endpunkt des neuen Objekts wird festgelegt
            this.ObjectStart     = startPoint;
            this.ActualObjectEnd = endPoint;

            //berechnet Maße
            GetMeasures();

            //Winkel wird abgespeichert
            GetAngle();

            this.Mode = mode;

            if (mode == LineMode.Normal)
            {
                color = Brushes.Black;
            }
            else
            {
                color = Brushes.LightSlateGray;
            }

            //neue Linie wird erstellt
            ThisObject = new Line()
            {
                //Linie von X1, Y1
                X1 = ObjectStart.X,
                Y1 = ObjectStart.Y,

                //zu X2, Y2
                X2 = ActualObjectEnd.X,
                Y2 = ActualObjectEnd.Y,

                Stroke          = color, //Farbe der Linie wird festgelegt
                StrokeThickness = 2      // Dicke: 2
            };

            //Objekt wird zum Canvas hinzugefügt
            MainWindow.ThisWindow.AddToCanvas(this.ThisObject);
        }
示例#26
0
        static void DrawOutline(CSGStadiumDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            var sides       = definition.sides;
            var topSides    = Mathf.Max(definition.topSides, 1) + 1;
            var bottomSides = Mathf.Max(definition.bottomSides, 1) + 1;

            var haveRoundedTop    = definition.haveRoundedTop;
            var haveRoundedBottom = definition.haveRoundedBottom;
            var haveCenter        = definition.haveCenter;
            //CSGOutlineRenderer.DrawLineLoop(vertices,     0, sides, lineMode: lineMode, thickness: kCapLineThickness);
            //CSGOutlineRenderer.DrawLineLoop(vertices, sides, sides, lineMode: lineMode, thickness: kCapLineThickness);

            var firstTopSide = definition.firstTopSide;
            var lastTopSide  = definition.lastTopSide;

            for (int k = firstTopSide; k <= lastTopSide; k++)
            {
                var sideLine  = !haveRoundedTop || (k == firstTopSide) || (k == lastTopSide);
                var thickness = (sideLine ? kSideLineThickness : kVertLineThickness);
                var dashSize  = (sideLine ? 0                  : kLineDash);
                CSGOutlineRenderer.DrawLine(vertices[k], vertices[sides + k], lineMode: lineMode, thickness: thickness, dashSize: dashSize);
            }

            var firstBottomSide = definition.firstBottomSide;
            var lastBottomSide  = definition.lastBottomSide;

            for (int k = firstBottomSide; k <= lastBottomSide; k++)
            {
                var sideLine  = haveCenter && (!haveRoundedBottom || (k == firstBottomSide) || (k == lastBottomSide));
                var thickness = (sideLine ? kSideLineThickness : kVertLineThickness);
                var dashSize  = (sideLine ? 0                  : kLineDash);
                CSGOutlineRenderer.DrawLine(vertices[k], vertices[sides + k], lineMode: lineMode, thickness: thickness, dashSize: dashSize);
            }

            //CSGOutlineRenderer.DrawLine(vertices[firstBottomSide], vertices[lastBottomSide], lineMode: lineMode, thickness: kVertLineThickness);
            //CSGOutlineRenderer.DrawLine(vertices[firstTopSide   ], vertices[lastTopSide   ], lineMode: lineMode, thickness: kVertLineThickness);

            //CSGOutlineRenderer.DrawLine(vertices[sides + firstBottomSide], vertices[sides + lastBottomSide], lineMode: lineMode, thickness: kVertLineThickness);
            //CSGOutlineRenderer.DrawLine(vertices[sides + firstTopSide   ], vertices[sides + lastTopSide   ], lineMode: lineMode, thickness: kVertLineThickness);
        }
示例#27
0
        /// <summary>
        /// Determines whether two lines or line segments intersects
        /// </summary>
        /// <param name="a1">The first point of the first line</param>
        /// <param name="b1">The second point of the first line</param>
        /// <param name="line1Mode">LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment</param>
        /// <param name="a2">The first point of the second line</param>
        /// <param name="b2">The second point of the second line</param>
        /// <param name="line2Mode">LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment</param>
        /// <returns>true if A1B1 intersects A2B2, otherwise returns false</returns>
        public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode)
        {
            double paramA1 = b1.Y - a1.Y;
            double paramB1 = a1.X - b1.X;
            double paramC1 = paramA1 * a1.X + paramB1 * a1.Y;

            double paramA2 = b2.Y - a2.Y;
            double paramB2 = a2.X - b2.X;
            double paramC2 = paramA2 * a2.X + paramB2 * a2.Y;

            double det = paramA1 * paramB2 - paramA2 * paramB1;

            if (det == 0)
            {
                return(false);
            }
            else
            {
                double x = (paramB2 * paramC1 - paramB1 * paramC2) / det;
                double y = (paramA1 * paramC2 - paramA2 * paramC1) / det;

                if (line1Mode == LineMode.LineSegment)
                {
                    if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y))
                    {
                        return(false);
                    }
                }

                if (line2Mode == LineMode.LineSegment)
                {
                    if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y))
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
示例#28
0
        public override int getReferences(ref Object3D[] references)
        {
            int references1 = base.getReferences(ref references);
            int num1        = references1;

            if (this.m_compositingMode != null)
            {
                ++references1;
            }
            if (this.m_polygonMode != null)
            {
                ++references1;
            }
            if (this.m_lineMode != null)
            {
                ++references1;
            }
            if (references != null)
            {
                if (this.m_compositingMode != null)
                {
                    references[num1++] = (Object3D)this.m_compositingMode;
                }
                if (this.m_polygonMode != null)
                {
                    references[num1++] = (Object3D)this.m_polygonMode;
                }
                if (this.m_lineMode != null)
                {
                    Object3D[] object3DArray = references;
                    int        index         = num1;
                    int        num2          = index + 1;
                    LineMode   lineMode      = this.m_lineMode;
                    object3DArray[index] = (Object3D)lineMode;
                }
            }
            return(references1);
        }
示例#29
0
 public void DrawContinuousLines(Vector3[] points, int startIndex, int length, LineMode lineMode = LineMode.NoZTest, float thickness = 1.0f, float dashSize = 0.0f)
 {
     DrawContinuousLines(UnityEditor.Handles.matrix, points, startIndex, length, UnityEditor.Handles.color, lineMode, thickness, dashSize);
 }
示例#30
0
        public void DrawLines(Matrix4x4 transformation, Vector3[] points, int startIndex, int length, Color color, LineMode lineMode = LineMode.NoZTest, float thickness = 1.0f, float dashSize = 0.0f)
        {
            switch (lineMode)
            {
            case LineMode.ZTest:    zTestLinesManager.DrawLines(transformation, points, startIndex, length, color, thickness, dashSize); break;

            case LineMode.NoZTest:  noZTestLinesManager.DrawLines(transformation, points, startIndex, length, color, thickness, dashSize); break;
            }
        }
示例#31
0
 public void DrawLines(Matrix4x4 transformation, Vector3[] points, int startIndex, int length, LineMode lineMode = LineMode.NoZTest, float thickness = 1.0f, float dashSize = 0.0f)
 {
     DrawLines(transformation, points, startIndex, length, UnityEditor.Handles.color, lineMode, thickness, dashSize);
 }
示例#32
0
        public void DrawLine(Matrix4x4 transformation, Vector3 from, Vector3 to, Color color, LineMode lineMode = LineMode.NoZTest, float thickness = 1.0f, float dashSize = 0.0f)
        {
            switch (lineMode)
            {
            case LineMode.ZTest:   zTestLinesManager.DrawLine(transformation, from, to, color, thickness, dashSize); break;

            case LineMode.NoZTest: noZTestLinesManager.DrawLine(transformation, from, to, color, thickness, dashSize); break;
            }
        }
 public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
 {
     Euclidean2DLocator target = new Euclidean2DLocator();
     Assert.False(target.IsOnLine(c, a, b, mode));
 }
示例#34
0
 /// <summary>
 /// Set display function.
 /// </summary>
 /// <param name="lineMode">Display line mode.</param>
 /// <param name="font">Display font.</param>
 public void SetFunction(LineMode lineMode, Font font)
 {
     uint cmd = 0x20;
     if (dataMode == DataMode.EightBit)
         cmd |= 0x10;
     if (lineMode == LineMode.TwoLine)
         cmd |= 0x08;
     switch (font)
     {
         case Font.FiveByEight:
             if (device == Device.HD44780)
                 cmd |= 0x00;
             else
                 throw new InvalidOperationException("Initialisation method not valid for specified device");
             break;
         case Font.FiveByTen:
             if (device == Device.HD44780)
                 cmd |= 0x04;
             else
                 throw new InvalidOperationException("Initialisation method not valid for specified device");
             break;
         case Font.SingleHeight:
             if ((device == Device.DOGM162_33V) || (device == Device.DOGM162_5V))
                 cmd |= 0x00;
             else
                 throw new InvalidOperationException("Font not valid for specified device");
             break;
         case Font.DoubleHeight:
             if ((device == Device.DOGM162_33V) || (device == Device.DOGM162_5V))
                 cmd |= 0x04;
             else
                 throw new InvalidOperationException("Font not valid for specified device");
             break;
     }
     WriteInternal(RegisterSelect.Command, cmd);
 }
        /// <summary>
        /// Determines whether specific coordinate is on the line defined by two points.
        /// </summary>
        /// <param name="c">The coordinate to be tested</param>
        /// <param name="a">The first point of the line.</param>
        /// <param name="b">The second point of the line.</param>
        /// <param name="mode">LineMode value that specifies whether AB should be treated as infinite line or as line segment</param>
        /// <returns>true if coordinate C is on line AB, otherwise false</returns>
        public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            /*
                    Express line in analytic form
                            paramA * x  +  paramB * y  +  paramC  =  0
            */

            double paramA = b.Y - a.Y;
            double paramB = a.X - b.X;
            double paramC = b.X * a.Y - a.X * b.Y;

            /*
                    induct coordinate C into equation of the line - if equation
                            paramA * c.X + paramB * c.Y + paramC = 0
                    is valid, point lies on the line
            */

            double cLineResult = paramA * c.X + paramB * c.Y + paramC;

            if (cLineResult != 0.0) {
                return false;
            }

            if (mode == LineMode.Line) {
                return true;
            }

            // compute distance of the C along vector AB
            double r;
            double dx = Math.Abs(b.X - a.X);
            double dy = Math.Abs(b.Y - a.Y);

            if (dx > dy) {
                r = (c.X - a.X) / (b.X - a.X);
            }
            else {
                r = (c.Y - a.Y) / (b.Y - a.Y);
            }

            if (r < 0.0 || r > 1.0) {
                return false;
            }
            else {
                return true;
            }
        }
        public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            Euclidean2DLocator target = new Euclidean2DLocator();

            Assert.True(target.IsOnLine(c, a, b, mode));
        }
        /// <summary>
        /// Calculates distance between a point and a great circle path connecting points A and B.
        /// </summary>
        /// <param name="c">The coordinate to compute the distance for.</param>
        /// <param name="a">The first point of the great circle.</param>
        /// <param name="b">The second point of the great circle.</param>
        /// <param name="mode">LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B.</param>
        /// <returns> The distance from c to great circle connecting points AB in units of the <see cref="Sphere2DCalculator.Radius"/> property.</returns>
        public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            double bearingAB = this.CalculateBearing(a, b);
            double bearingAC = this.CalculateBearing(a, c);

            double distAC = this.CalculateDistance(a, c);

            //Sign can be used to determine if point is left/right of the great circle
            double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius);

            if (mode == LineMode.Line) {
                return distCircleC;
            }
            else {
                double bearingBA = this.CalculateBearing(b, a);
                double bearingBC = this.CalculateBearing(b, c);

                if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) {
                    return distAC;
                }
                else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) {
                    return this.CalculateDistance(b, c);
                }
                else {
                    return distCircleC;
                }
            }
        }
        /// <summary>
        /// Calculates distance between a point and a line AB
        /// </summary>
        /// <param name="c">The coordinate to compute the distance for.</param>
        /// <param name="a">One point of the line.</param>
        /// <param name="b">Another point of the line.</param>
        /// <param name="mode">LineMode value that specifies whether AB should be treated as infinite line or as line segment.</param>
        /// <returns> The distance from C to line AB in coordinate's units.</returns>
        public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode)
        {
            if (a.Equals2D(b)) {
                return this.CalculateDistance(c, a);
            }

            double deltaX = b.X - a.X;
            double deltaY = b.Y - a.Y;

            if (mode == LineMode.LineSegment) {
                /*
                        Let P be the point of perpendicular projection of C on AB.  The parameter
                        r, which indicates P's position along AB, is computed by the dot product
                        of AC and AB divided by the square of the length of AB:

                                        AC dot AB
                                r = ---------
                                        ||AB||^2

                        r has the following meaning:

                                r=0      P = A
                                r=1      P = B
                                r<0      P is on the backward extension of AB
                                r>1      P is on the forward extension of AB
                                0<r<1    P is interior to AB
                */

                double r = ((c.X - a.X) * deltaX + (c.Y - a.Y) * deltaY) / (deltaX * deltaX + deltaY * deltaY);

                if (r <= 0.0) {
                    return this.CalculateDistance(c, a);
                }

                if (r >= 1.0) {
                    return this.CalculateDistance(c, b);
                }
            }

            /*
                    Use another parameter s to indicate the location along PC, with the  following meaning:
                             s<0      C is left of AB
                             s>0      C is right of AB
                             s=0      C is on AB

                    (principialy the same as r - only use perpendicular vector)

                    Compute s as follows:

                                (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
                        s = -----------------------------
                                                        L^2
            */

            double s = ((a.Y - c.Y) * deltaX - (a.X - c.X) * deltaY) / (deltaX * deltaX + deltaY * deltaY);

            /*
                    Then the distance from C to P = |s|*L.
            */

            return Math.Abs(s) * Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
        }