Ejemplo n.º 1
0
        /// <summary>
        /// 获取挡格附近出生点
        /// </summary>
        /// <param name="line"></param>
        /// <param name="offset"></param>
        /// <param name="bornPoint"></param>
        /// <returns></returns>
        public override bool GetBornPoint(LineSegment2D line, double offset, ref Double2 bornPoint)
        {
            Double2 dirNormal = line.normalizedDir;
            Double2 diff      = this.circleCenter - line.startPoint;

            if (diff == Double2.zero)
            {
                bornPoint = line.startPoint + line.normalizedDir * (this.radius + offset);
                return(true);
            }
            else
            {
                Double2 projectoint = Double2.Project(diff, dirNormal) + line.startPoint;
                diff = this.circleCenter - projectoint;
                double dis = this.radius * this.radius - diff.sqrMagnitude;
                if (dis <= 0)
                {
                    return(false);
                }
                else
                {
                    dis = (float)System.Math.Sqrt(dis) + offset;
                    double value = Double2.Dot(dirNormal, line.endPoint - projectoint);
                    if (value > 0)
                    {
                        bornPoint = projectoint + dirNormal * dis;
                    }
                    else
                    {
                        bornPoint = projectoint - dirNormal * dis;
                    }
                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 点导几何元素的投影点
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public Double2 ProjectPoint(Double2 pt)
        {
            Double2 diff = pt - this.startPoint;

            if (diff == Double2.zero)
            {
                return(pt);
            }
            return(Double2.Project(diff, this.normalizedDir) + this.startPoint);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 求轴向量
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public Double2 AixsVector(Double2 pt)
        {
            Double2 diff = pt - this.startPoint;

            if (diff == Double2.zero)
            {
                return(Double2.zero);
            }
            return(diff - Double2.Project(diff, this.normalizedDir));
        }