Beispiel #1
0
	/**
	 * InsidePolygon
	 *
	 * @param verts
	 * @param num
	 * @param pt
	 * @param ray
	 * @return boolean
	 */
	private bool InsidePolygon(Point[] verts, int num, Point pt, Ray ray)
	{
		int cross = 0;
		int xindex, yindex, index = 0;
		double xtest, ytest, x0, y0, x1, y1;

		if(MaxComp == 0)
		{
			xindex = 1;
			yindex = 2;
			xtest = pt.GetY();
			ytest = pt.GetZ();
		}
		else if(MaxComp == 1)
		{
			xindex = 0;
			yindex = 2;
			xtest = pt.GetX();
			ytest = pt.GetZ();
		}
		else
		{
			xindex = 0;
			yindex = 1;
			xtest = pt.GetX();
			ytest = pt.GetY();
		}
		x0 = GetCoord(verts[num - 1], xindex) - xtest;
		y0 = GetCoord(verts[num - 1], yindex) - ytest;
		while(num-- != 0)
		{
			x1 = GetCoord(verts[index], xindex) - xtest;
			y1 = GetCoord(verts[index], yindex) - ytest;
			if(y0 > 0.0f)
			{
				if(y1 <= 0.0f)
				{
					if(x1 * y0 > y1 * x0)
					{
						cross++;
					}
				}
			}
			else
			{
				if(y1 > 0.0f)
				{
					if(x0 * y1 > y0 * x1)
					{
						cross++;
					}
				}
			}
			x0 = x1;
			y0 = y1;
			index++;
		}
		return ((cross & 1) == 1);
	}
Beispiel #2
0
    public bool IsEqual(Point rhs)
    {
        if (rhs.GetX() == this.x && rhs.GetY() == this.y && rhs.GetRotation() == this.rotation) {
            return true;
        }

        return false;
    }
Beispiel #3
0
	/**
	 * SphereObj
	 *
	 * @param objmaterial
	 * @param newobjID
	 * @param neworigin
	 * @param newradius
	 * @param MaxX
	 * @param MinX
	 * @param MaxY
	 * @param MinY
	 * @param MaxZ
	 * @param MinZ
	 */
	public SphereObj(Material objmaterial, int newobjID, Point neworigin, double newradius, Point max, Point min)
		: base(objmaterial, newobjID)
	{
		Origin = neworigin;
		Radius = newradius;

		RadiusSquare = Radius * Radius;
		GetMax().SetX(Origin.GetX() + Radius);
		GetMax().SetY(Origin.GetY() + Radius);
		GetMax().SetZ(Origin.GetZ() + Radius);
		GetMin().SetX(Origin.GetX() - Radius);
		GetMin().SetY(Origin.GetY() - Radius);
		GetMin().SetZ(Origin.GetZ() - Radius);
		if(GetMax().GetX() > max.GetX())
		{
			max.SetX(GetMax().GetX());
		}
		if(GetMax().GetY() > max.GetY())
		{
			max.SetY(GetMax().GetY());
		}
		if(GetMax().GetZ() > max.GetZ())
		{
			max.SetZ(GetMax().GetZ());
		}
		if(GetMin().GetX() < min.GetX())
		{
			min.SetX(GetMin().GetX());
		}
		if(GetMin().GetY() < min.GetY())
		{
			min.SetY(GetMin().GetY());
		}
		if(GetMin().GetZ() < min.GetZ())
		{
			min.SetZ(GetMin().GetZ());
		}
	}
Beispiel #4
0
        /**
         * SphereObj
         *
         * @param objmaterial
         * @param newobjID
         * @param neworigin
         * @param newradius
         * @param MaxX
         * @param MinX
         * @param MaxY
         * @param MinY
         * @param MaxZ
         * @param MinZ
         */
        public SphereObj(Material objmaterial, int newobjID, Point neworigin, double newradius, Point max, Point min)
            : base(objmaterial, newobjID)
        {
            Origin = neworigin;
            Radius = newradius;

            RadiusSquare = Radius * Radius;
            GetMax().SetX(Origin.GetX() + Radius);
            GetMax().SetY(Origin.GetY() + Radius);
            GetMax().SetZ(Origin.GetZ() + Radius);
            GetMin().SetX(Origin.GetX() - Radius);
            GetMin().SetY(Origin.GetY() - Radius);
            GetMin().SetZ(Origin.GetZ() - Radius);
            if (GetMax().GetX() > max.GetX())
            {
                max.SetX(GetMax().GetX());
            }
            if (GetMax().GetY() > max.GetY())
            {
                max.SetY(GetMax().GetY());
            }
            if (GetMax().GetZ() > max.GetZ())
            {
                max.SetZ(GetMax().GetZ());
            }
            if (GetMin().GetX() < min.GetX())
            {
                min.SetX(GetMin().GetX());
            }
            if (GetMin().GetY() < min.GetY())
            {
                min.SetY(GetMin().GetY());
            }
            if (GetMin().GetZ() < min.GetZ())
            {
                min.SetZ(GetMin().GetZ());
            }
        }
Beispiel #5
0
    public CarteDistance(Point cible, Graph g, float SPAN, float WALL, float CELL, GameObject cases, Transform parant)
    {
        this.parant = parant;
        this.cases  = cases;
        this.cible  = cible;
        this.SPAN   = SPAN;
        this.WALL   = WALL;
        this.CELL   = CELL;
        size        = (int)Mathf.Sqrt(g.GetSize());
        decalage    = new Vector3((WALL + CELL) * (-size / 2.0f) * SPAN, 0, (WALL + CELL) * (-size / 2.0f) * SPAN);
        tab         = new int[size, size];
        Point p = g.getPosition(cible.GetX(), cible.GetY());

        for (int x = 0; x < size; x++)
        {
            for (int y = 0; y < size; y++)
            {
                tab[x, y] = -1;
            }
        }
        PointSuivant(p, 0);
        CreateCase();
    }
Beispiel #6
0
        private static AffineTransform BuildToCornerTransform(Point center, Point gradientCenterLineRightCorner)
        {
            double scale = 1d / (center.Distance(gradientCenterLineRightCorner));
            double sin   = (gradientCenterLineRightCorner.GetY() - center.GetY()) * scale;
            double cos   = (gradientCenterLineRightCorner.GetX() - center.GetX()) * scale;

            if (Math.Abs(cos) < ZERO_EPSILON)
            {
                cos = 0d;
                sin = sin > 0d ? 1d : -1d;
            }
            else
            {
                if (Math.Abs(sin) < ZERO_EPSILON)
                {
                    sin = 0d;
                    cos = cos > 0d ? 1d : -1d;
                }
            }
            double m02 = center.GetX() * (1d - cos) + center.GetY() * sin;
            double m12 = center.GetY() * (1d - cos) - center.GetX() * sin;

            return(new AffineTransform(cos, sin, -sin, cos, m02, m12));
        }
Beispiel #7
0
 /**
  * Sub
  *
  * @param op1
  * @param op2
  * @return Vector
  */
 public Vector Sub(Point op1, Point op2)
 {
     Set(op1.GetX() - op2.GetX(), op1.GetY() - op2.GetY(), op1.GetZ() - op2.GetZ());
     return(this);
 }
        /* NGeohash round-trip for given precision. */

        private Point alignGeohash(Point p)
        {
            return(GeohashUtils.Decode(GeohashUtils.EncodeLatLon(p.GetY(), p.GetX(), maxLength), ctx));
        }
Beispiel #9
0
        public void GetY_Test()
        {
            var point = new Point(3, 5);

            Assert.AreEqual(5, point.GetY());
        }
Beispiel #10
0
 public override void SetCoordinates(String[] coordinates, Point startPoint)
 {
     String[] normalizedCoords = new String[coordinates.Length * 2];
     // An H or h command is equivalent to an L or l command with 0 specified for the y coordinate.
     for (int i = 0; i < coordinates.Length; i++)
     {
         normalizedCoords[i * 2]     = coordinates[i];
         normalizedCoords[i * 2 + 1] = IsRelative() ? "0" : SvgCssUtils.ConvertDoubleToString(startPoint.GetY());
     }
     base.SetCoordinates(normalizedCoords, startPoint);
 }
Beispiel #11
0
	/**
	 * OctNode
	 *
	 * @param max
	 * @param min
	 */
	public OctNode(Point max, Point min)
	{
		Initialize();
		CreateFaces(max.GetX(), min.GetX(), max.GetY(), min.GetY(), max.GetZ(), min.GetZ());
	}
Beispiel #12
0
 public SpatialRelation Relate(Point pt)
 {
     //TODO if not jtsPoint, test against bbox to avoid JTS if disjoint
     var jtsPoint = (NtsPoint)(pt is NtsPoint ? pt : ctx.MakePoint(pt.GetX(), pt.GetY()));
     return geom.Disjoint(jtsPoint.GetGeom()) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS;
 }
Beispiel #13
0
		/**
	 * FindCorner
	 *
	 * @param view
	 * @param up
	 * @param plane
	 * @param origin
	 */
		public void FindCorner (Vector view, Vector up, Vector plane, Point origin)
		{
			x = origin.GetX ();
			y = origin.GetY ();
			z = origin.GetZ ();
			Add (view);
			Add (up);
			Add (plane);
		}
Beispiel #14
0
		/**
	 * Combine
	 *
	 * @param pt
	 * @param vector
	 * @param ptscale
	 * @param vecscale
	 * @return Point
	 */
		public Point Combine (Point pt, Vector vector, double ptscale, double vecscale)
		{
			x = ptscale * pt.GetX () + vecscale * vector.GetX ();
			y = ptscale * pt.GetY () + vecscale * vector.GetY ();
			z = ptscale * pt.GetZ () + vecscale * vector.GetZ ();
			return (this);
		}
Beispiel #15
0
 public void KengTrue(Point p)
 {
     keng[p.GetX(), p.GetY()] = true;
 }
Beispiel #16
0
		public float PtLineDistSq(Point pt) {
			return PtLineDistSq(GetX1(), GetY1(), GetX2(), GetY2(), pt.GetX(),
					pt.GetY());
		}
Beispiel #17
0
	/**
	 * GetCoord
	 *
	 * @param pt
	 * @param index
	 * @return double
	 */
	private double GetCoord(Point pt, int index)
	{
		if(index == 0)
			return (pt.GetX());
		else if(index == 1)
			return (pt.GetY());
		else
			return (pt.GetZ());
	}
Beispiel #18
0
	/**
	 * Intersect
	 *
	 * @param ray
	 * @param intersect
	 * @param Threshold
	 * @return OctNode
	 */
	public OctNode Intersect(Ray ray, Point intersect, double Threshold)
	{
		Vector delta = new Vector(0.0f, 0.0f, 0.0f);
		double current = 0.0f;
		double t;
		int[] facehits = new int[3];
		facehits[0] = -1;
		facehits[1] = -1;
		facehits[2] = -1;
		OctNode adjacent = null;

		Face[] OFaces = this.OctFaces;
		Face MAXXF = OFaces[MAXX];
		Face MAXYF = OFaces[MAXY];
		Face MAXZF = OFaces[MAXZ];
		Face MINXF = OFaces[MINX];
		Face MINYF = OFaces[MINY];
		Face MINZF = OFaces[MINZ];

		if(ray.GetDirection().GetX() != 0.0)
		{
			t = -(ray.GetOrigin().GetX() - OctFaces[MAXX].GetVert(0).GetX()) / ray.GetDirection().GetX();
			if(t > Threshold && t > current)
			{
				intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
				if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
					(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
				{
					current = t;
					facehits[0] = MAXX;
					delta.SetX(Threshold);
				}
			}
			t = -(ray.GetOrigin().GetX() - OctFaces[MINX].GetVert(0).GetX()) / ray.GetDirection().GetX();
			if(t > Threshold && t > current)
			{
				intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
				if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
					(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
				{
					current = t;
					facehits[0] = MINX;
					delta.SetX(-Threshold);
				}
			}
		}
		if(ray.GetDirection().GetY() != 0.0)
		{
			t = -(ray.GetOrigin().GetY() - OctFaces[MAXY].GetVert(0).GetY()) / ray.GetDirection().GetY();
			if(t > Threshold)
			{
				if(t > current)
				{
					intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
					if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
						(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
					{
						current = t;
						facehits[0] = MAXY;
						delta.Set(0.0f, Threshold, 0.0f);
					}
				}
				else if(t == current)
				{
					facehits[1] = MAXY;
					delta.SetY(Threshold);
				}
			}
			t = -(ray.GetOrigin().GetY() - OctFaces[MINY].GetVert(0).GetY()) / ray.GetDirection().GetY();
			if(t > Threshold)
			{
				if(t > current)
				{
					intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
					if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
						(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
					{
						current = t;
						facehits[0] = MINY;
						delta.Set(0.0f, -Threshold, 0.0f);
					}
				}
				else if(t == current)
				{
					facehits[1] = MINY;
					delta.SetY(-Threshold);
				}
			}
		}
		if(ray.GetDirection().GetZ() != 0.0)
		{
			t = -(ray.GetOrigin().GetZ() - OctFaces[MAXZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
			if(t > Threshold)
			{
				if(t > current)
				{
					intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
					if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
						(intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()))
					{
						current = t;
						facehits[0] = MAXZ;
						delta.Set(0.0f, 0.0f, Threshold);
					}
				}
				else if(t == current)
				{
					if(facehits[1] < 0)
					{
						facehits[1] = MAXZ;
					}
					else
					{
						facehits[2] = MAXZ;
					}
					delta.SetZ(Threshold);
				}
			}
			t = -(ray.GetOrigin().GetZ() - OctFaces[MINZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
			if(t > Threshold)
			{
				if(t > current)
				{
					intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
					if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
						(intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()))
					{
						current = t;
						facehits[0] = MINZ;
						delta.Set(0.0f, 0.0f, -Threshold);
					}
				}
				else if(t == current)
				{
					if(facehits[1] < 0)
					{
						facehits[1] = MINZ;
					}
					else
					{
						facehits[2] = MINZ;
					}
					delta.SetZ(-Threshold);
				}
			}
		}
		if(facehits[0] >= MAXX)
		{
			intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, current);
			intersect.Add(delta);
			adjacent = Adjacent[facehits[0]];
			if(facehits[1] >= MAXX)
			{
				if(adjacent != null)
				{
					adjacent = adjacent.GetAdjacent(facehits[1]);
					if(facehits[2] >= MAXX)
					{
						if(adjacent != null)
						{
							adjacent = adjacent.GetAdjacent(facehits[2]);
						}
						else
						{
							adjacent = null;
						}
					}
				}
				else
				{
					adjacent = null;
				}
			}
		}
		return (adjacent);
	}
Beispiel #19
0
	/**
	 * FindTreeNode
	 *
	 * @param point
	 * @return OctNode
	 */
	public OctNode FindTreeNode(Point point)
	{
		OctNode found;

		if(point.GetX() < OctFaces[MINX].GetVert(0).GetX() || point.GetX() >= OctFaces[MAXX].GetVert(0).GetX())
		{
			return (null);
		}
		if(point.GetY() < OctFaces[MINY].GetVert(0).GetY() || point.GetY() >= OctFaces[MAXY].GetVert(0).GetY())
		{
			return (null);
		}
		if(point.GetZ() < OctFaces[MINZ].GetVert(0).GetZ() || point.GetZ() >= OctFaces[MAXZ].GetVert(0).GetZ())
		{
			return (null);
		}
		if(Child[0] != null)
		{
			for(int i = 0; i < 8; i++)
			{
				found = Child[i].FindTreeNode(point);
				if(found != null)
				{
					return (found);
				}
			}
		}
		return (this);
	}
Beispiel #20
0
 public Rectangle(Point top_left, Point bottom_right)
 {
     this.top_left     = top_left;
     this.bottom_right = bottom_right;
     corners           = new Point[] { top_left, new Point(bottom_right.GetX(), top_left.GetY()),
                                       new Point(top_left.GetX(), bottom_right.GetY()), bottom_right };
     size = new double[] { corners[0].Distance(corners[1]), corners[1].Distance(corners[1]) };
 }
Beispiel #21
0
		/**
	 * Point
	 *
	 * @param newpoint
	 */
		public Point (Point newpoint)
		{
			Set (newpoint.GetX (), newpoint.GetY (), newpoint.GetZ ());
		}
 public override void SetCoordinates(String[] inputCoordinates, Point startPoint)
 {
     String[] normalizedCoords = new String[LineTo.ARGUMENT_SIZE];
     // An H or h command is equivalent to an L or l command with 0 specified for the y coordinate.
     normalizedCoords[0] = inputCoordinates[0];
     normalizedCoords[1] = IsRelative() ? "0" : SvgCssUtils.ConvertDoubleToString(startPoint.GetY());
     base.SetCoordinates(normalizedCoords, startPoint);
 }
Beispiel #23
0
    public void Link(GameObject crystal)
    {
        if (crystal != null)//水晶连线   && linkStop == false
        {
            if (!draw)//如果还没开始画线
            {
                //if (EnergyManager.Instance.accessibleEnergy > 0)
                {
                    #region
                    float x = 0, z = 0; int kx = -1, ky = -1;
                    linePoints = new Vector3[2];
                    linePoints[0] = crystal.transform.position;
                    z = EnergyManager.Instance.HeroMagicCircle.getz(linePoints[0].z);
                    if (z == EnergyManager.Instance.HeroMagicCircle.rowKey[2])
                        x = EnergyManager.Instance.HeroMagicCircle.getx1(linePoints[0].x);
                    else if (z == EnergyManager.Instance.HeroMagicCircle.rowKey[0] || z == EnergyManager.Instance.HeroMagicCircle.rowKey[4])
                        x = EnergyManager.Instance.HeroMagicCircle.getx2(linePoints[0].x);
                    else
                        x = EnergyManager.Instance.HeroMagicCircle.getx3(linePoints[0].x);
                    kx = EnergyManager.Instance.HeroMagicCircle.getKx(x);
                    ky = EnergyManager.Instance.HeroMagicCircle.getKy(z);
                    if (kx != -1)
                    {
                        l1 = new Point( kx , ky);
                        draw = true;
                        //EnergyManager.Instance.MinusEnergy(1);
                    }
                    screenSpace = Camera.main.WorldToScreenPoint(crystal.transform.position);
                    linePoints[1] = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
                    temp1 = new VectorLine("3DLine", linePoints, Color.green, lineMaterial, 8.0f);
                    temp2 = new VectorLine("3DLine", linePoints, Color.green, lineMaterial2, 15.0f);
                    temp1.Draw3DAuto();
                    temp2.Draw3DAuto();
                    #endregion
                }
                //else
                //{
                //    //linkStop = true;
                //}
            }
            else
            {
                #region
                float x = 0, z = 0; int kx = -1, ky = -1;
                linePoints[1] = crystal.transform.position;
                z = EnergyManager.Instance.HeroMagicCircle.getz(linePoints[1].z);
                if (z == EnergyManager.Instance.HeroMagicCircle.rowKey[2])
                    x = EnergyManager.Instance.HeroMagicCircle.getx1(linePoints[1].x);
                else if (z == EnergyManager.Instance.HeroMagicCircle.rowKey[0] || z == EnergyManager.Instance.HeroMagicCircle.rowKey[4])
                    x = EnergyManager.Instance.HeroMagicCircle.getx2(linePoints[1].x);
                else
                    x = EnergyManager.Instance.HeroMagicCircle.getx3(linePoints[1].x);
                kx = EnergyManager.Instance.HeroMagicCircle.getKx(x);
                ky = EnergyManager.Instance.HeroMagicCircle.getKy(z);
                l2 = new Point(kx , ky);
                if (l2 == l1)//连自己=>取消连线
                {
                    VectorLine.Destroy(ref temp1);
                    VectorLine.Destroy(ref temp2);
                    //EnergyManager.Instance.MinusEnergy(-1);
                }
                else if (EnergyManager.Instance.HeroMagicCircle.IsOperable(new Line(l1,l2)))
                {
                    if (kx != -1 && !EnergyManager.Instance.HeroMagicCircle.GetLine(l1, l2) && EnergyManager.Instance.HeroMagicCircle.GetLineSwitch(l1.GetX(), l1.GetY(), l2.GetX(), l2.GetY()))//画线
                    {
                        //AddLine(l1, l2);
                        if (EnergyManager.Instance.accessibleEnergy>0)
                        {
                            temp1.Draw3D();
                            temp2.Draw3D();
                            line[l1.GetUni(), l2.GetUni()] = temp1; line2[l1.GetUni(), l2.GetUni()] = temp2;
                            EnergyManager.Instance.HeroMagicCircle.LineTrue(l1.GetUni(), l2.GetUni());
                            EnergyManager.Instance.MinusEnergy(1);
                        }
                        else
                        {
                            VectorLine.Destroy(ref temp1);
                            VectorLine.Destroy(ref temp2);
                            GuideText.Instance.ReturnText("LinkNeedEnergy");
                        }
                    }
                    else if (EnergyManager.Instance.HeroMagicCircle.GetLine(l1, l2))//删线
                    {

                        // Debug.Log("delete");
                        DeleteLine(l1, l2);
                        VectorLine.Destroy(ref temp1);
                        VectorLine.Destroy(ref temp2);
                        GuideText.Instance.GuideLevel(2, 33, "RedundentLink");
                        GuideText.Instance.GuideLevel(3, 33, "RedundentLink");
                        //EnergyManager.Instance.MinusEnergy(-1);
                        //linkStop = true;
                    }
                }
                else
                {
                    GuideText.Instance.ReturnText("NoJumpLink");
                    return;
                }
                draw = false;
                #endregion
            }
        }
    }
 protected override Node GetNode(Point p, int level)
 {
     return(new GhCell(GeohashUtils.EncodeLatLon(p.GetY(), p.GetX(), level), this));//args are lat,lon (y,x)
 }
Beispiel #25
0
	/**
	 * RenderScene
	 */
	public void RenderScene(Canvas canvas, int width, int section, int nsections)
	{
		Vector view = camera.GetViewDir();
		Vector up = camera.GetOrthoUp();
		Vector plane = new Vector();
		Vector horIncr = new Vector();
		Vector vertIncr = new Vector();
		double ylen = camera.GetFocalDist() * (double)Math.Tan(0.5f * camera.GetFOV());
		double xlen = ylen * canvas.GetWidth() / canvas.GetHeight();
		Point upleft = new Point();
		Point upright = new Point();
		Point lowleft = new Point();
		Point basepoint = new Point();
		Point current;
		Ray eyeRay = new Ray();
		int ypixel, xpixel;

		RayID = 1;
		plane.Cross(view, up);
		view.Scale(camera.GetFocalDist());
		up.Scale(ylen);
		plane.Scale(-xlen);
		upleft.FindCorner(view, up, plane, camera.GetPosition());
		plane.Negate();
		upright.FindCorner(view, up, plane, camera.GetPosition());
		up.Negate();
		plane.Negate();
		lowleft.FindCorner(view, up, plane, camera.GetPosition());
		horIncr.Sub(upright, upleft);
		horIncr.Scale(horIncr.Length() / ((double)canvas.GetWidth()));
		vertIncr.Sub(lowleft, upleft);
		vertIncr.Scale(vertIncr.Length() / ((double)canvas.GetHeight()));
		basepoint.Set(upleft.GetX() + 0.5f * (horIncr.GetX() + vertIncr.GetX()), upleft.GetY() + 0.5f * (horIncr.GetY() + vertIncr.GetY()),
			upleft.GetZ() + 0.5f * (horIncr.GetZ() + vertIncr.GetZ()));
		eyeRay.SetOrigin(camera.GetPosition());

		int xstart = section * width / nsections;
		int xend = xstart + width / nsections;

		Console.WriteLine("+" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());

		for(ypixel = 0; ypixel < canvas.GetHeight(); ypixel++)
		{
			current = new Point(basepoint);
			for(xpixel = 0; xpixel < canvas.GetWidth(); xpixel++)
			{
				if(xpixel >= xstart && xpixel < xend)
				{
					Color color = new Color(0.0f, 0.0f, 0.0f);
					eyeRay.GetDirection().Sub(current, eyeRay.GetOrigin());
					eyeRay.GetDirection().Normalize();
					eyeRay.SetID(RayID);
					this.RayID = this.RayID + 1;
					Shade(octree, eyeRay, color, 1.0f, 0, 0);
					canvas.Write(Brightness, xpixel, ypixel, color);
				}
				current.Add(horIncr);
			}
			basepoint.Add(vertIncr);
		}
		Console.WriteLine("-" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
	}
Beispiel #26
0
 /// <summary>
 /// Gets the coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// for the current shape.
 /// </summary>
 /// <param name="shape">The current shape.</param>
 /// <param name="previousShape">The previous shape which can affect the coordinates of the current shape.</param>
 /// <param name="pathProperties">
 /// The operator and all arguments as a
 /// <see>String[]</see>
 /// </param>
 /// <returns>
 /// a
 /// <see>String[]</see>
 /// of coordinates that shall be passed to
 /// <see cref="iText.Svg.Renderers.Path.IPathShape.SetCoordinates(System.String[], iText.Kernel.Geom.Point)"/>
 /// </returns>
 private String[] GetShapeCoordinates(IPathShape shape, IPathShape previousShape, String[] pathProperties)
 {
     if (shape is ClosePath)
     {
         return(null);
     }
     String[] shapeCoordinates = null;
     if (shape is SmoothSCurveTo || shape is QuadraticSmoothCurveTo)
     {
         String[] startingControlPoint = new String[2];
         if (previousShape != null)
         {
             Point previousEndPoint = previousShape.GetEndingPoint();
             //if the previous command was a Bezier curve, use its last control point
             if (previousShape is IControlPointCurve)
             {
                 Point lastControlPoint = ((IControlPointCurve)previousShape).GetLastControlPoint();
                 float reflectedX       = (float)(2 * previousEndPoint.GetX() - lastControlPoint.GetX());
                 float reflectedY       = (float)(2 * previousEndPoint.GetY() - lastControlPoint.GetY());
                 startingControlPoint[0] = SvgCssUtils.ConvertFloatToString(reflectedX);
                 startingControlPoint[1] = SvgCssUtils.ConvertFloatToString(reflectedY);
             }
             else
             {
                 startingControlPoint[0] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetX());
                 startingControlPoint[1] = SvgCssUtils.ConvertDoubleToString(previousEndPoint.GetY());
             }
         }
         else
         {
             // TODO RND-951
             startingControlPoint[0] = pathProperties[0];
             startingControlPoint[1] = pathProperties[1];
         }
         shapeCoordinates = Concatenate(startingControlPoint, pathProperties);
     }
     if (shapeCoordinates == null)
     {
         shapeCoordinates = pathProperties;
     }
     return(shapeCoordinates);
 }
Beispiel #27
0
	/**
	 * ReadPoly
	 *
	 * @param infile
	 * @param ObjID
	 * @return int
	 */
	private int ReadPoly(int ObjID)
	{
		String temp;
		double[] input = new double[3];
		int i, j, k;
		int numpolys = 0;
		int numverts;
		bool trimesh, vertnormal;
		Point max = new Point(MaxX, MaxY, MaxZ);
		Point min = new Point(MinX, MinY, MinZ);

		temp = readString();
		temp = readString();
		Material theMaterial = ReadMaterial();
		temp = readString();
		if(temp.Substring(7).Equals("POLYSET_TRI_MESH"))
		{
			trimesh = true;
		}
		else
		{
			trimesh = false;
		}
		temp = readString();
		if(temp.Substring(11).Equals("PER_VERTEX_NORMAL"))
		{
			vertnormal = true;
		}
		else
		{
			vertnormal = false;
		}
		for(i = 0; i < 4; i++)
		{
			temp = readString();
		}
		temp = temp.Substring(11);
		numpolys = Int32.Parse(temp);
		ObjID++;
		for(i = 0; i < numpolys; i++)
		{
			temp = readString();
			temp = readString();
			temp = temp.Substring(16);
			numverts = Int32.Parse(temp);
			Point[] vertices = new Point[numverts];
			for(j = 0; j < numverts; j++)
			{
				temp = readString();
				temp = temp.Substring(8);
				for(k = 0; k < 2; k++)
				{
					input[k] = (double)Double.Parse(temp.Substring(0, temp.IndexOf(' ')));
					temp = temp.Substring(temp.IndexOf(' ') + 1);
				}
				input[2] = (double)Double.Parse(temp);
				vertices[j] = new Point(input[0], input[1], input[2]);
				if(vertnormal)
				{
					temp = readString();
				}
			}
			temp = readString();
			TriangleObj newtriangle;
			PolygonObj newpoly;
			ObjNode newnode;
			if(trimesh)
			{
				newtriangle = new TriangleObj(theMaterial, ObjID, numverts, vertices, max, min);
				newnode = new ObjNode(newtriangle, objects);
			}
			else
			{
				newpoly = new PolygonObj(theMaterial, ObjID, numverts, vertices, max, min);
				newnode = new ObjNode(newpoly, objects);
			}
			objects = newnode;
		}
		temp = readString();
		MaxX = max.GetX();
		MaxY = max.GetY();
		MaxZ = max.GetZ();
		MinX = min.GetX();
		MinY = min.GetY();
		MinZ = min.GetZ();

		return (numpolys);
	}
Beispiel #28
0
	/**
	 * PolyTypeObj
	 *
	 * @param objmaterial
	 * @param newobjID
	 * @param numverts
	 * @param vertices
	 * @param MaxX
	 * @param MinX
	 * @param MaxY
	 * @param MinY
	 * @param MaxZ
	 * @param MinZ
	 */
	protected PolyTypeObj(Material objmaterial, int newobjID, int numverts, Point[] vertices,
		Point max, Point min)
		: base(objmaterial, newobjID)
	{
		numVertices = numverts;
		Vertices = vertices;

		CalculateNormal();
		Vector temp = new Vector(Vertices[0].GetX(), Vertices[0].GetY(), Vertices[0].GetZ());
		D = -Normal.Dot(temp);
		GetMax().Set(Vertices[0].GetX(), Vertices[0].GetY(), Vertices[0].GetZ());
		GetMin().Set(Vertices[0].GetX(), Vertices[0].GetY(), Vertices[0].GetZ());
		for(int i = 1; i < numVertices; i++)
		{
			if(Vertices[i].GetX() > GetMax().GetX())
			{
				GetMax().SetX(Vertices[i].GetX());
			}
			else if(Vertices[i].GetX() < GetMin().GetX())
			{
				GetMin().SetX(Vertices[i].GetX());
			}
			if(Vertices[i].GetY() > GetMax().GetY())
			{
				GetMax().SetY(Vertices[i].GetY());
			}
			else if(Vertices[i].GetY() < GetMin().GetY())
			{
				GetMin().SetY(Vertices[i].GetY());
			}
			if(Vertices[i].GetZ() > GetMax().GetZ())
			{
				GetMax().SetZ(Vertices[i].GetZ());
			}
			else if(Vertices[i].GetZ() < GetMin().GetZ())
			{
				GetMin().SetZ(Vertices[i].GetZ());
			}
		}
		if(GetMax().GetX() > max.GetX())
		{
			max.SetX(GetMax().GetX());
		}
		if(GetMax().GetY() > max.GetY())
		{
			max.SetY(GetMax().GetY());
		}
		if(GetMax().GetZ() > max.GetZ())
		{
			max.SetZ(GetMax().GetZ());
		}
		if(GetMin().GetX() < min.GetX())
		{
			min.SetX(GetMin().GetX());
		}
		if(GetMin().GetY() < min.GetY())
		{
			min.SetY(GetMin().GetY());
		}
		if(GetMin().GetZ() < min.GetZ())
		{
			min.SetZ(GetMin().GetZ());
		}
	}
Beispiel #29
0
        ///<summary>
        /// Проверка находится ли точка Р на стороне прямоугольника между точками pBegin, pEnd.
        /// Возвращает true если точка расположена на стороне между pBegin и pEnd
        ///
        /// </summary>
        /// <param name="p">проверяемая точка</param>
        /// <param name="pBegin">Вершина(точка) начала стороны</param>
        /// <param name="pEnd">Вершина(точка) конца стороны</param>
        private bool IsPointOnSide(Point p, Point pBegin, Point pEnd)

        {
            bool result = false;

            if (!PointOnLine(p, pBegin, pEnd))
            {
                result = false;
            }
            else if (IsPointOnSideAxis(p.GetX(), pBegin.GetX(), pEnd.GetX()) && IsPointOnSideAxis(p.GetY(), pBegin.GetY(), pEnd.GetY()))
            {
                result = true;
                Console.WriteLine("Найдена точка на стороне");
            }

            return(result);
        }
        private IEnumerable <string> Search(bool reverse)
        {
            var searcher = new IndexSearcher(_directory, true);

            Point littleMermaid = _ctx.MakePoint(12.599239, 55.692848);

            var sort = new Sort(new SortField(SpartialFieldName, new PointVectorDistanceFieldComparatorSource(littleMermaid, _strategy), reverse));

            var q = _strategy.MakeQuery(new SpatialArgs(SpatialOperation.IsWithin, _ctx.MakeCircle(littleMermaid.GetX(), littleMermaid.GetY(), DistanceUtils.Dist2Degrees(20000, DistanceUtils.EARTH_MEAN_RADIUS_KM))));

            TopDocs hits = searcher.Search(q, null, 100, sort);


            var result = new string[hits.ScoreDocs.Length];

            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc match = hits.ScoreDocs[i];

                Document doc = searcher.Doc(match.Doc);
                result[i] = doc.Get(IdFieldName);
            }
            searcher.Dispose();

            return(result);
        }
Beispiel #31
0
        /// <summary>
        /// Рассчитывает и возвращает площадь четырехугольника. Округление до 6 знаков после запятой.
        /// </summary>
        /// <returns></returns>

        public double Square()
        {
            double square = (Math.Abs(0.5 * (vertex1.GetX() * vertex2.GetY() + vertex2.GetX() * vertex3.GetY() + vertex3.GetX() * vertex4.GetY() + vertex4.GetX() * vertex1.GetY() - (vertex2.GetX() * vertex1.GetY() + vertex3.GetX() * vertex2.GetY() + vertex4.GetX() * vertex3.GetY() + vertex1.GetX() * vertex4.GetY()))));

            return(square); // Площадь произвольного не самопересекающегося четырёхугольника, заданного на плоскости координатами своих вершин
        }
Beispiel #32
0
 private static double GetLengthOfSide(Point first, Point second)
 {
     return(Math.Sqrt(Math.Pow(first.GetX() - second.GetX(), 2) + Math.Pow(first.GetY() - second.GetY(), 2)));
 }
 public double Distance(Point @from, Point to)
 {
     return Distance(from, to.GetX(), to.GetY());
 }
Beispiel #34
0
        /**
         * PolyTypeObj
         *
         * @param objmaterial
         * @param newobjID
         * @param numverts
         * @param vertices
         * @param MaxX
         * @param MinX
         * @param MaxY
         * @param MinY
         * @param MaxZ
         * @param MinZ
         */
        protected PolyTypeObj(Material objmaterial, int newobjID, int numverts, Point[] vertices,
                              Point max, Point min)
            : base(objmaterial, newobjID)
        {
            numVertices = numverts;
            Vertices    = vertices;

            CalculateNormal();
            Vector temp = new Vector(Vertices [0].GetX(), Vertices [0].GetY(), Vertices [0].GetZ());

            D = -Normal.Dot(temp);
            GetMax().Set(Vertices [0].GetX(), Vertices [0].GetY(), Vertices [0].GetZ());
            GetMin().Set(Vertices [0].GetX(), Vertices [0].GetY(), Vertices [0].GetZ());
            for (int i = 1; i < numVertices; i++)
            {
                if (Vertices [i].GetX() > GetMax().GetX())
                {
                    GetMax().SetX(Vertices [i].GetX());
                }
                else if (Vertices [i].GetX() < GetMin().GetX())
                {
                    GetMin().SetX(Vertices [i].GetX());
                }
                if (Vertices [i].GetY() > GetMax().GetY())
                {
                    GetMax().SetY(Vertices [i].GetY());
                }
                else if (Vertices [i].GetY() < GetMin().GetY())
                {
                    GetMin().SetY(Vertices [i].GetY());
                }
                if (Vertices [i].GetZ() > GetMax().GetZ())
                {
                    GetMax().SetZ(Vertices [i].GetZ());
                }
                else if (Vertices [i].GetZ() < GetMin().GetZ())
                {
                    GetMin().SetZ(Vertices [i].GetZ());
                }
            }
            if (GetMax().GetX() > max.GetX())
            {
                max.SetX(GetMax().GetX());
            }
            if (GetMax().GetY() > max.GetY())
            {
                max.SetY(GetMax().GetY());
            }
            if (GetMax().GetZ() > max.GetZ())
            {
                max.SetZ(GetMax().GetZ());
            }
            if (GetMin().GetX() < min.GetX())
            {
                min.SetX(GetMin().GetX());
            }
            if (GetMin().GetY() < min.GetY())
            {
                min.SetY(GetMin().GetY());
            }
            if (GetMin().GetZ() < min.GetZ())
            {
                min.SetZ(GetMin().GetZ());
            }
        }
Beispiel #35
0
 public void DrawFood()
 {
     grid.SetTile(new Vector3Int(pos.GetX(), pos.GetY(), 0), tile);
 }
 public virtual double GetAutoOrientAngle(MarkerSvgNodeRenderer marker, bool reverse)
 {
     if (points.Count > 1)
     {
         Vector v = new Vector(0, 0, 0);
         if (SvgConstants.Attributes.MARKER_END.Equals(marker.attributesAndStyles.Get(SvgConstants.Tags.MARKER)))
         {
             Point lastPoint         = points[points.Count - 1];
             Point secondToLastPoint = points[points.Count - 2];
             v = new Vector((float)(lastPoint.GetX() - secondToLastPoint.GetX()), (float)(lastPoint.GetY() - secondToLastPoint
                                                                                          .GetY()), 0f);
         }
         else
         {
             if (SvgConstants.Attributes.MARKER_START.Equals(marker.attributesAndStyles.Get(SvgConstants.Tags.MARKER)))
             {
                 Point firstPoint  = points[0];
                 Point secondPoint = points[1];
                 v = new Vector((float)(secondPoint.GetX() - firstPoint.GetX()), (float)(secondPoint.GetY() - firstPoint.GetY
                                                                                             ()), 0f);
             }
         }
         Vector xAxis    = new Vector(1, 0, 0);
         double rotAngle = SvgCoordinateUtils.CalculateAngleBetweenTwoVectors(xAxis, v);
         return(v.Get(1) >= 0 && !reverse ? rotAngle : rotAngle * -1f);
     }
     return(0);
 }
    static void Main()
    {
        Point pt = new Point(10, 20);

        Console.WriteLine("{0},{1}", pt.GetX(), pt.GetY());
    }
Beispiel #38
0
 /**
  * Point
  *
  * @param newpoint
  */
 public Point(Point newpoint)
 {
     Set(newpoint.GetX(), newpoint.GetY(), newpoint.GetZ());
 }
        private static Point GetNextPoint(Point segStart, Point segEnd, float dist)
        {
            Point vector     = ComponentwiseDiff(segEnd, segStart);
            Point unitVector = GetUnitVector(vector);

            return(new Point(segStart.GetX() + dist * unitVector.GetX(), segStart.GetY() + dist * unitVector.GetY()));
        }
Beispiel #40
0
 public double DistanceTo(Point p)
 {
     return Math.Sqrt(Math.Pow(p.GetX (), 2) + Math.Pow(p.GetY(), 2));
 }
Beispiel #41
0
        /// <summary>Reads and processes all the data of the InputMeta.</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void ReadAll()
        {
            if (@in.ReadInt() != unchecked ((int)(0x9AC6CDD7)))
            {
                throw new PdfException(PdfException.NotAPlaceableWindowsMetafile);
            }
            @in.ReadWord();
            left   = @in.ReadShort();
            top    = @in.ReadShort();
            right  = @in.ReadShort();
            bottom = @in.ReadShort();
            inch   = @in.ReadWord();
            state.SetScalingX((float)(right - left) / (float)inch * 72f);
            state.SetScalingY((float)(bottom - top) / (float)inch * 72f);
            state.SetOffsetWx(left);
            state.SetOffsetWy(top);
            state.SetExtentWx(right - left);
            state.SetExtentWy(bottom - top);
            @in.ReadInt();
            @in.ReadWord();
            @in.Skip(18);
            int tsize;
            int function;

            cb.SetLineCapStyle(PdfCanvasConstants.LineCapStyle.ROUND);
            cb.SetLineJoinStyle(PdfCanvasConstants.LineJoinStyle.ROUND);
            for (; ;)
            {
                int lenMarker = @in.GetLength();
                tsize = @in.ReadInt();
                if (tsize < 3)
                {
                    break;
                }
                function = @in.ReadWord();
                switch (function)
                {
                case 0: {
                    break;
                }

                case META_CREATEPALETTE:
                case META_CREATEREGION:
                case META_DIBCREATEPATTERNBRUSH: {
                    state.AddMetaObject(new MetaObject());
                    break;
                }

                case META_CREATEPENINDIRECT: {
                    MetaPen pen = new MetaPen();
                    pen.Init(@in);
                    state.AddMetaObject(pen);
                    break;
                }

                case META_CREATEBRUSHINDIRECT: {
                    MetaBrush brush = new MetaBrush();
                    brush.Init(@in);
                    state.AddMetaObject(brush);
                    break;
                }

                case META_CREATEFONTINDIRECT: {
                    MetaFont font = new MetaFont();
                    font.Init(@in);
                    state.AddMetaObject(font);
                    break;
                }

                case META_SELECTOBJECT: {
                    int idx = @in.ReadWord();
                    state.SelectMetaObject(idx, cb);
                    break;
                }

                case META_DELETEOBJECT: {
                    int idx = @in.ReadWord();
                    state.DeleteMetaObject(idx);
                    break;
                }

                case META_SAVEDC: {
                    state.SaveState(cb);
                    break;
                }

                case META_RESTOREDC: {
                    int idx = @in.ReadShort();
                    state.RestoreState(idx, cb);
                    break;
                }

                case META_SETWINDOWORG: {
                    state.SetOffsetWy(@in.ReadShort());
                    state.SetOffsetWx(@in.ReadShort());
                    break;
                }

                case META_SETWINDOWEXT: {
                    state.SetExtentWy(@in.ReadShort());
                    state.SetExtentWx(@in.ReadShort());
                    break;
                }

                case META_MOVETO: {
                    int   y = @in.ReadShort();
                    Point p = new Point(@in.ReadShort(), y);
                    state.SetCurrentPoint(p);
                    break;
                }

                case META_LINETO: {
                    int   y = @in.ReadShort();
                    int   x = @in.ReadShort();
                    Point p = state.GetCurrentPoint();
                    cb.MoveTo(state.TransformX((int)p.GetX()), state.TransformY((int)p.GetY()));
                    cb.LineTo(state.TransformX(x), state.TransformY(y));
                    cb.Stroke();
                    state.SetCurrentPoint(new Point(x, y));
                    break;
                }

                case META_POLYLINE: {
                    state.SetLineJoinPolygon(cb);
                    int len = @in.ReadWord();
                    int x   = @in.ReadShort();
                    int y   = @in.ReadShort();
                    cb.MoveTo(state.TransformX(x), state.TransformY(y));
                    for (int k = 1; k < len; ++k)
                    {
                        x = @in.ReadShort();
                        y = @in.ReadShort();
                        cb.LineTo(state.TransformX(x), state.TransformY(y));
                    }
                    cb.Stroke();
                    break;
                }

                case META_POLYGON: {
                    if (IsNullStrokeFill(false))
                    {
                        break;
                    }
                    int len = @in.ReadWord();
                    int sx  = @in.ReadShort();
                    int sy  = @in.ReadShort();
                    cb.MoveTo(state.TransformX(sx), state.TransformY(sy));
                    for (int k = 1; k < len; ++k)
                    {
                        int x = @in.ReadShort();
                        int y = @in.ReadShort();
                        cb.LineTo(state.TransformX(x), state.TransformY(y));
                    }
                    cb.LineTo(state.TransformX(sx), state.TransformY(sy));
                    StrokeAndFill();
                    break;
                }

                case META_POLYPOLYGON: {
                    if (IsNullStrokeFill(false))
                    {
                        break;
                    }
                    int   numPoly = @in.ReadWord();
                    int[] lens    = new int[numPoly];
                    for (int k = 0; k < lens.Length; ++k)
                    {
                        lens[k] = @in.ReadWord();
                    }
                    for (int j = 0; j < lens.Length; ++j)
                    {
                        int len = lens[j];
                        int sx  = @in.ReadShort();
                        int sy  = @in.ReadShort();
                        cb.MoveTo(state.TransformX(sx), state.TransformY(sy));
                        for (int k = 1; k < len; ++k)
                        {
                            int x = @in.ReadShort();
                            int y = @in.ReadShort();
                            cb.LineTo(state.TransformX(x), state.TransformY(y));
                        }
                        cb.LineTo(state.TransformX(sx), state.TransformY(sy));
                    }
                    StrokeAndFill();
                    break;
                }

                case META_ELLIPSE: {
                    if (IsNullStrokeFill(state.GetLineNeutral()))
                    {
                        break;
                    }
                    int b = @in.ReadShort();
                    int r = @in.ReadShort();
                    int t = @in.ReadShort();
                    int l = @in.ReadShort();
                    cb.Arc(state.TransformX(l), state.TransformY(b), state.TransformX(r), state.TransformY(t), 0, 360);
                    StrokeAndFill();
                    break;
                }

                case META_ARC: {
                    if (IsNullStrokeFill(state.GetLineNeutral()))
                    {
                        break;
                    }
                    float yend   = state.TransformY(@in.ReadShort());
                    float xend   = state.TransformX(@in.ReadShort());
                    float ystart = state.TransformY(@in.ReadShort());
                    float xstart = state.TransformX(@in.ReadShort());
                    float b      = state.TransformY(@in.ReadShort());
                    float r      = state.TransformX(@in.ReadShort());
                    float t      = state.TransformY(@in.ReadShort());
                    float l      = state.TransformX(@in.ReadShort());
                    float cx     = (r + l) / 2;
                    float cy     = (t + b) / 2;
                    float arc1   = GetArc(cx, cy, xstart, ystart);
                    float arc2   = GetArc(cx, cy, xend, yend);
                    arc2 -= arc1;
                    if (arc2 <= 0)
                    {
                        arc2 += 360;
                    }
                    cb.Arc(l, b, r, t, arc1, arc2);
                    cb.Stroke();
                    break;
                }

                case META_PIE: {
                    if (IsNullStrokeFill(state.GetLineNeutral()))
                    {
                        break;
                    }
                    float yend   = state.TransformY(@in.ReadShort());
                    float xend   = state.TransformX(@in.ReadShort());
                    float ystart = state.TransformY(@in.ReadShort());
                    float xstart = state.TransformX(@in.ReadShort());
                    float b      = state.TransformY(@in.ReadShort());
                    float r      = state.TransformX(@in.ReadShort());
                    float t      = state.TransformY(@in.ReadShort());
                    float l      = state.TransformX(@in.ReadShort());
                    float cx     = (r + l) / 2;
                    float cy     = (t + b) / 2;
                    float arc1   = GetArc(cx, cy, xstart, ystart);
                    float arc2   = GetArc(cx, cy, xend, yend);
                    arc2 -= arc1;
                    if (arc2 <= 0)
                    {
                        arc2 += 360;
                    }
                    IList <double[]> ar = PdfCanvas.BezierArc(l, b, r, t, arc1, arc2);
                    if (ar.Count == 0)
                    {
                        break;
                    }
                    double[] pt = ar[0];
                    cb.MoveTo(cx, cy);
                    cb.LineTo(pt[0], pt[1]);
                    for (int k = 0; k < ar.Count; ++k)
                    {
                        pt = ar[k];
                        cb.CurveTo(pt[2], pt[3], pt[4], pt[5], pt[6], pt[7]);
                    }
                    cb.LineTo(cx, cy);
                    StrokeAndFill();
                    break;
                }

                case META_CHORD: {
                    if (IsNullStrokeFill(state.GetLineNeutral()))
                    {
                        break;
                    }
                    float yend   = state.TransformY(@in.ReadShort());
                    float xend   = state.TransformX(@in.ReadShort());
                    float ystart = state.TransformY(@in.ReadShort());
                    float xstart = state.TransformX(@in.ReadShort());
                    float b      = state.TransformY(@in.ReadShort());
                    float r      = state.TransformX(@in.ReadShort());
                    float t      = state.TransformY(@in.ReadShort());
                    float l      = state.TransformX(@in.ReadShort());
                    float cx     = (r + l) / 2;
                    float cy     = (t + b) / 2;
                    float arc1   = GetArc(cx, cy, xstart, ystart);
                    float arc2   = GetArc(cx, cy, xend, yend);
                    arc2 -= arc1;
                    if (arc2 <= 0)
                    {
                        arc2 += 360;
                    }
                    IList <double[]> ar = PdfCanvas.BezierArc(l, b, r, t, arc1, arc2);
                    if (ar.Count == 0)
                    {
                        break;
                    }
                    double[] pt = ar[0];
                    cx = (float)pt[0];
                    cy = (float)pt[1];
                    cb.MoveTo(cx, cy);
                    for (int k = 0; k < ar.Count; ++k)
                    {
                        pt = ar[k];
                        cb.CurveTo(pt[2], pt[3], pt[4], pt[5], pt[6], pt[7]);
                    }
                    cb.LineTo(cx, cy);
                    StrokeAndFill();
                    break;
                }

                case META_RECTANGLE: {
                    if (IsNullStrokeFill(true))
                    {
                        break;
                    }
                    float b = state.TransformY(@in.ReadShort());
                    float r = state.TransformX(@in.ReadShort());
                    float t = state.TransformY(@in.ReadShort());
                    float l = state.TransformX(@in.ReadShort());
                    cb.Rectangle(l, b, r - l, t - b);
                    StrokeAndFill();
                    break;
                }

                case META_ROUNDRECT: {
                    if (IsNullStrokeFill(true))
                    {
                        break;
                    }
                    float h = state.TransformY(0) - state.TransformY(@in.ReadShort());
                    float w = state.TransformX(@in.ReadShort()) - state.TransformX(0);
                    float b = state.TransformY(@in.ReadShort());
                    float r = state.TransformX(@in.ReadShort());
                    float t = state.TransformY(@in.ReadShort());
                    float l = state.TransformX(@in.ReadShort());
                    cb.RoundRectangle(l, b, r - l, t - b, (h + w) / 4);
                    StrokeAndFill();
                    break;
                }

                case META_INTERSECTCLIPRECT: {
                    float b = state.TransformY(@in.ReadShort());
                    float r = state.TransformX(@in.ReadShort());
                    float t = state.TransformY(@in.ReadShort());
                    float l = state.TransformX(@in.ReadShort());
                    cb.Rectangle(l, b, r - l, t - b);
                    cb.EoClip();
                    cb.NewPath();
                    break;
                }

                case META_EXTTEXTOUT: {
                    int y     = @in.ReadShort();
                    int x     = @in.ReadShort();
                    int count = @in.ReadWord();
                    int flag  = @in.ReadWord();
                    int x1    = 0;
                    int y1    = 0;
                    int x2    = 0;
                    int y2    = 0;
                    if ((flag & (MetaFont.ETO_CLIPPED | MetaFont.ETO_OPAQUE)) != 0)
                    {
                        x1 = @in.ReadShort();
                        y1 = @in.ReadShort();
                        x2 = @in.ReadShort();
                        y2 = @in.ReadShort();
                    }
                    byte[] text = new byte[count];
                    int    k;
                    for (k = 0; k < count; ++k)
                    {
                        byte c = (byte)@in.ReadByte();
                        if (c == 0)
                        {
                            break;
                        }
                        text[k] = c;
                    }
                    String s;
                    try {
                        s = iText.IO.Util.JavaUtil.GetStringForBytes(text, 0, k, "Cp1252");
                    }
                    catch (ArgumentException) {
                        s = iText.IO.Util.JavaUtil.GetStringForBytes(text, 0, k);
                    }
                    OutputText(x, y, flag, x1, y1, x2, y2, s);
                    break;
                }

                case META_TEXTOUT: {
                    int    count = @in.ReadWord();
                    byte[] text  = new byte[count];
                    int    k;
                    for (k = 0; k < count; ++k)
                    {
                        byte c = (byte)@in.ReadByte();
                        if (c == 0)
                        {
                            break;
                        }
                        text[k] = c;
                    }
                    String s;
                    try {
                        s = iText.IO.Util.JavaUtil.GetStringForBytes(text, 0, k, "Cp1252");
                    }
                    catch (ArgumentException) {
                        s = iText.IO.Util.JavaUtil.GetStringForBytes(text, 0, k);
                    }
                    count = count + 1 & 0xfffe;
                    @in.Skip(count - k);
                    int y = @in.ReadShort();
                    int x = @in.ReadShort();
                    OutputText(x, y, 0, 0, 0, 0, 0, s);
                    break;
                }

                case META_SETBKCOLOR: {
                    state.SetCurrentBackgroundColor(@in.ReadColor());
                    break;
                }

                case META_SETTEXTCOLOR: {
                    state.SetCurrentTextColor(@in.ReadColor());
                    break;
                }

                case META_SETTEXTALIGN: {
                    state.SetTextAlign(@in.ReadWord());
                    break;
                }

                case META_SETBKMODE: {
                    state.SetBackgroundMode(@in.ReadWord());
                    break;
                }

                case META_SETPOLYFILLMODE: {
                    state.SetPolyFillMode(@in.ReadWord());
                    break;
                }

                case META_SETPIXEL: {
                    Color color = @in.ReadColor();
                    int   y     = @in.ReadShort();
                    int   x     = @in.ReadShort();
                    cb.SaveState();
                    cb.SetFillColor(color);
                    cb.Rectangle(state.TransformX(x), state.TransformY(y), .2f, .2f);
                    cb.Fill();
                    cb.RestoreState();
                    break;
                }

                case META_DIBSTRETCHBLT:
                case META_STRETCHDIB: {
                    int rop = @in.ReadInt();
                    if (function == META_STRETCHDIB)
                    {
                        /*int usage = */
                        @in.ReadWord();
                    }
                    int    srcHeight  = @in.ReadShort();
                    int    srcWidth   = @in.ReadShort();
                    int    ySrc       = @in.ReadShort();
                    int    xSrc       = @in.ReadShort();
                    float  destHeight = state.TransformY(@in.ReadShort()) - state.TransformY(0);
                    float  destWidth  = state.TransformX(@in.ReadShort()) - state.TransformX(0);
                    float  yDest      = state.TransformY(@in.ReadShort());
                    float  xDest      = state.TransformX(@in.ReadShort());
                    byte[] b          = new byte[tsize * 2 - (@in.GetLength() - lenMarker)];
                    for (int k = 0; k < b.Length; ++k)
                    {
                        b[k] = (byte)@in.ReadByte();
                    }
                    try {
                        cb.SaveState();
                        cb.Rectangle(xDest, yDest, destWidth, destHeight);
                        cb.Clip();
                        cb.NewPath();
                        ImageData       bmpImage     = ImageDataFactory.CreateBmp(b, true, b.Length);
                        PdfImageXObject imageXObject = new PdfImageXObject(bmpImage);
                        float           width        = destWidth * bmpImage.GetWidth() / srcWidth;
                        float           height       = -destHeight *bmpImage.GetHeight() / srcHeight;

                        float x = xDest - destWidth * xSrc / srcWidth;
                        float y = yDest + destHeight * ySrc / srcHeight - height;
                        cb.AddXObject(imageXObject, new Rectangle(x, y, width, height));
                        cb.RestoreState();
                    }
                    catch (Exception) {
                    }
                    // empty on purpose
                    break;
                }
                }
                @in.Skip(tsize * 2 - (@in.GetLength() - lenMarker));
            }
            state.Cleanup(cb);
        }
Beispiel #42
0
 /// <summary>
 /// This method adds a point to this statistics.
 /// </summary>
 public void AddPoint(Point point, bool updateVisualizer = true)
 {
     AddPoint(point.GetX(), point.GetY(), updateVisualizer);
 }
Beispiel #43
0
 protected internal override Cell GetCell(Point p, int level)
 {
     return(new GhCell(this, GeohashUtils.EncodeLatLon(p.GetY(), p.GetX
                                                           (), level)));
 }
Beispiel #44
0
 public Node GetNode(Point c)
 {
     int TempX = (int) c.GetX();
     int TempY = (int) c.GetY();
     if(TempX >= 0 && TempX < xLength && TempY >= 0 && TempY < yLength) {
         return GridArray[TempX, TempY];
     }
     return null;
 }
Beispiel #45
0
	/**
	 * ReadSphere
	 *
	 * @param infile
	 * @param ObjID
	 * @return int
	 */
	private int ReadSphere(int ObjID)
	{
		String temp;
		double[] input = new double[3];
		int i;
		double radius;
		Point max = new Point(MaxX, MaxY, MaxZ);
		Point min = new Point(MinX, MinY, MinZ);

		temp = readString();
		temp = readString();
		Material theMaterial = ReadMaterial();
		temp = readString();
		temp = temp.Substring(9);
		for(i = 0; i < 2; i++)
		{
			input[i] = (double)Double.Parse(temp.Substring(0, temp.IndexOf(' ')));
			temp = temp.Substring(temp.IndexOf(' ') + 1);
		}
		input[2] = (double)Double.Parse(temp);
		Point origin = new Point(input[0], input[1], input[2]);
		temp = readString();
		temp = temp.Substring(9);
		radius = (double)Double.Parse(temp);
		for(i = 0; i < 7; i++)
		{
			temp = readString();
		}
		SphereObj newsphere = new SphereObj(theMaterial, ++ObjID, origin, radius, max, min);
		ObjNode newnode = new ObjNode(newsphere, objects);
		objects = newnode;
		MaxX = max.GetX();
		MaxY = max.GetY();
		MaxZ = max.GetZ();
		MinX = min.GetX();
		MinY = min.GetY();
		MinZ = min.GetZ();

		return (1);
	}
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Constructs a {@code LinearGradientBrush}.
         *
         * @param start the gradient axis start {@code Point} in user space
         * @param end the gradient axis end {@code Point} in user space
         * @param fractions numbers ranging from 0 to 255 specifying the
         *                  distribution of colors along the gradient
         * @param colors array of colors corresponding to each fractional Value
         * @param fillType either {@code NO_CYCLE}, {@code REFLECT},
         *                    or {@code REPEAT}
         * @param gradientTransform transform to apply to the gradient
         *
         * @throws NullPointerException
         * if one of the points is null,
         * or {@code fractions} array is null,
         * or {@code colors} array is null,
         * or {@code cycleMethod} is null,
         * or {@code colorSpace} is null,
         * or {@code gradientTransform} is null
         * @throws IllegalArgumentException
         * if start and end points are the same points,
         * or {@code fractions.length != colors.length},
         * or {@code colors} is less than 2 in size,
         * or a {@code fractions} Value is less than 0.0 or greater than 1.0,
         * or the {@code fractions} are not provided in strictly increasing order
         */
        public LinearGradientBrush(Point start, Point end,
                                   int[] fractions, Color[] colors,
                                   AffineTransform gradientTransform, int fillType)
        {
            if (fractions == null)
            {
                throw new NullReferenceException("Fractions array cannot be null");
            }

            if (colors == null)
            {
                throw new NullReferenceException("Colors array cannot be null");
            }

            if (gradientTransform == null)
            {
                throw new NullReferenceException("Gradient transform cannot be " +
                                                 "null");
            }

            if (fractions.Length != colors.Length)
            {
                throw new ArgumentException("Colors and fractions must " +
                                            "have equal size");
            }

            if (colors.Length < 2)
            {
                throw new ArgumentException("User must specify at least " +
                                            "2 colors");
            }

            // check that values are in the proper range and progress
            // in increasing order from 0 to 1
            int previousFraction = -255;

            for (int i = 0; i < fractions.Length; i++)
            {
                int currentFraction = fractions[i];
                if (currentFraction < 0 || currentFraction > 255)
                {
                    throw new ArgumentException("Fraction values must " +
                                                "be in the range 0 to 255: " +
                                                currentFraction);
                }

                if (currentFraction <= previousFraction)
                {
                    throw new ArgumentException("Keyframe fractions " +
                                                "must be increasing: " +
                                                currentFraction);
                }

                previousFraction = currentFraction;
            }

            // We have to deal with the cases where the first gradient stop is not
            // equal to 0 and/or the last gradient stop is not equal to 1.
            // In both cases, create a new point and replicate the previous
            // extreme point's color.
            bool fixFirst = false;
            bool fixLast  = false;
            int  len      = fractions.Length;
            int  off      = 0;

            if (fractions[0] != 0)
            {
                // first stop is not equal to zero, fix this condition
                fixFirst = true;
                len++;
                off++;
            }
            if (fractions[fractions.Length - 1] != 255)
            {
                // last stop is not equal to one, fix this condition
                fixLast = true;
                len++;
            }

            this._fractions = new int[len];
            Array.Copy(fractions, 0, this._fractions, off, fractions.Length);
            this._colors = new Color[len];
            Array.Copy(colors, 0, this._colors, off, colors.Length);

            if (fixFirst)
            {
                this._fractions[0] = 0;
                this._colors[0]    = colors[0];
            }
            if (fixLast)
            {
                this._fractions[len - 1] = 255;
                this._colors[len - 1]    = colors[colors.Length - 1];
            }

            // copy the gradient transform
            this._gradientTransform = new AffineTransform(gradientTransform);

            // determine transparency
            bool opaque = true;

            for (int i = 0; i < colors.Length; i++)
            {
                opaque = opaque && (colors[i].GetAlpha() == 0xff);
            }
            _transparency = opaque ? Color.OPAQUE : Color.TRANSLUCENT;

            // check input parameters
            if (start == null || end == null)
            {
                throw new NullReferenceException("Start and end points must be" +
                                                 "non-null");
            }

            if (start.Equals(end))
            {
                throw new ArgumentException("Start point cannot equal" +
                                            "endpoint");
            }

            // copy the points...
            this._start = new Point(start.GetX(), start.GetY());
            this._end   = new Point(end.GetX(), end.GetY());

            Rectangle   rectangle = new Rectangle(start, end);
            float       dx        = start.X - end.X;
            float       dy        = start.Y - end.Y;
            double      angle     = MathEx.Atan2(dy, dx);
            int         intAngle  = SingleFP.FromDouble(angle);
            RectangleFP r         = Utils.ToRectangleFP(rectangle);

            _wrappedBrushFP = new LinearGradientBrushFP(r.GetLeft(), r.GetTop(),
                                                        r.GetRight(), r.GetBottom(),
                                                        intAngle);
            for (int i = 0; i < colors.Length; i++)
            {
                ((LinearGradientBrushFP)_wrappedBrushFP).SetGradientColor
                    (SingleFP.FromFloat(fractions[i] / 100.0f),
                    colors[i]._value);
            }
            ((LinearGradientBrushFP)_wrappedBrushFP).UpdateGradientTable();
            _wrappedBrushFP.SetMatrix(Utils.ToMatrixFP(gradientTransform));
            _wrappedBrushFP.FillMode = fillType;
        }
Beispiel #47
0
	/**
	 * Sub
	 *
	 * @param op1
	 * @param op2
	 * @return Vector
	 */
	public Vector Sub(Point op1, Point op2)
	{
		Set(op1.GetX() - op2.GetX(), op1.GetY() - op2.GetY(), op1.GetZ() - op2.GetZ());
		return (this);
	}
 /// <summary>Returns the componentwise difference between two vectors</summary>
 /// <param name="minuend">first vector</param>
 /// <param name="subtrahend">second vector</param>
 /// <returns>first vector .- second vector</returns>
 private static Point ComponentwiseDiff(Point minuend, Point subtrahend)
 {
     return(new Point(minuend.GetX() - subtrahend.GetX(), minuend.GetY() - subtrahend.GetY()));
 }
Beispiel #49
0
	/**
	 * CreateChildren
	 *
	 * @param objects
	 * @param depth
	 */
	private void CreateChildren(ObjNode objects, int depth)
	{

		double maxX = OctFaces[MAXX].GetVert(0).GetX();
		double minX = OctFaces[MINX].GetVert(0).GetX();
		double maxY = OctFaces[MAXY].GetVert(0).GetY();
		double minY = OctFaces[MINY].GetVert(0).GetY();
		double maxZ = OctFaces[MAXZ].GetVert(0).GetZ();
		double minZ = OctFaces[MINZ].GetVert(0).GetZ();
		Point midpt = new Point((maxX + minX) / 2.0f, (maxY + minY) / 2.0f, (maxZ + minZ) / 2.0f);
		Point max = new Point();
		Point min = new Point();
		ObjNode currentnode;
		int i;

		max.Set(maxX, maxY, maxZ);
		min.Set(midpt.GetX(), midpt.GetY(), midpt.GetZ());
		Child[0] = new OctNode(max, min);
		max.Set(maxX, midpt.GetY(), maxZ);
		min.Set(midpt.GetX(), minY, midpt.GetZ());
		Child[1] = new OctNode(max, min);
		max.Set(maxX, midpt.GetY(), midpt.GetZ());
		min.Set(midpt.GetX(), minY, minZ);
		Child[2] = new OctNode(max, min);
		max.Set(maxX, maxY, midpt.GetZ());
		min.Set(midpt.GetX(), midpt.GetY(), minZ);
		Child[3] = new OctNode(max, min);
		max.Set(midpt.GetX(), maxY, maxZ);
		min.Set(minX, midpt.GetY(), midpt.GetZ());
		Child[4] = new OctNode(max, min);
		max.Set(midpt.GetX(), midpt.GetY(), maxZ);
		min.Set(minX, minY, midpt.GetZ());
		Child[5] = new OctNode(max, min);
		max.Set(midpt.GetX(), midpt.GetY(), midpt.GetZ());
		min.Set(minX, minY, minZ);
		Child[6] = new OctNode(max, min);
		max.Set(midpt.GetX(), maxY, midpt.GetZ());
		min.Set(minX, midpt.GetY(), minZ);
		Child[7] = new OctNode(max, min);

		OctNode[] adj = this.Adjacent;
		OctNode[] chld = this.Child;

		OctNode adj0 = adj[0];
		OctNode adj1 = adj[1];
		OctNode adj2 = adj[2];
		OctNode adj3 = adj[3];
		OctNode adj4 = adj[4];
		OctNode adj5 = adj[5];

		OctNode chld0 = chld[0];
		OctNode chld1 = chld[1];
		OctNode chld2 = chld[2];
		OctNode chld3 = chld[3];
		OctNode chld4 = chld[4];
		OctNode chld5 = chld[5];
		OctNode chld6 = chld[6];
		OctNode chld7 = chld[7];

		Child[0].FormAdjacent(adj0, adj1, adj2, chld4, chld1, chld3);
		Child[1].FormAdjacent(adj0, chld0, adj2, chld5, adj4, chld2);
		Child[2].FormAdjacent(adj0, chld3, chld1, chld6, adj4, adj5);
		Child[3].FormAdjacent(adj0, adj1, chld0, chld7, chld2, adj5);
		Child[4].FormAdjacent(chld0, adj1, adj2, adj3, chld5, chld7);
		Child[5].FormAdjacent(chld1, chld4, adj2, adj3, adj4, chld6);
		Child[6].FormAdjacent(chld2, chld7, chld5, adj3, adj4, adj5);
		Child[7].FormAdjacent(chld3, adj1, chld4, adj3, chld6, adj5);
		if(objects != null)
		{
			currentnode = objects;
		}
		else
		{
			currentnode = ObjList;
		}
		while(currentnode != null)
		{
			ObjectType currentobj = currentnode.GetObj();
			for(i = 0; i < 8; i++)
			{
				OctNode cc = chld[i];
				max = cc.GetFace(0).GetVert(0);
				min = cc.GetFace(5).GetVert(3);
				if(!((currentobj.GetMin().GetX() > max.GetX()) ||
					(currentobj.GetMax().GetX() < min.GetX())))
				{
					if(!((currentobj.GetMin().GetY() > max.GetY()) ||
						(currentobj.GetMax().GetY() < min.GetY())))
					{
						if(!((currentobj.GetMin().GetZ() > max.GetZ()) ||
							(currentobj.GetMax().GetZ() < min.GetZ())))
						{
							ObjNode newnode = new ObjNode(currentobj, Child[i].GetList());
							cc.SetList(newnode);
							cc.IncNumObj();
						}
					}
				}
			}
			currentnode = currentnode.Next();
		}
		if(objects == null)
		{
			NumObj = 0;
			ObjList = null;
		}
		if(depth < MaxDepth)
		{
			for(i = 0; i < 8; i++)
			{
				if(Child[i].GetNumObj() > MaxObj)
				{
					Child[i].CreateChildren(null, depth + 1);
				}
			}
		}
	}
Beispiel #50
0
        private float AdjustPositionAfterRotation(float angle, float maxWidth, float maxHeight)
        {
            if (angle != 0)
            {
                AffineTransform t       = AffineTransform.GetRotateInstance(angle);
                Point           p00     = t.Transform(new Point(0, 0), new Point());
                Point           p01     = t.Transform(new Point(0, height), new Point());
                Point           p10     = t.Transform(new Point((float)width, 0), new Point());
                Point           p11     = t.Transform(new Point((float)width, height), new Point());
                double[]        xValues = new double[] { p01.GetX(), p10.GetX(), p11.GetX() };
                double[]        yValues = new double[] { p01.GetY(), p10.GetY(), p11.GetY() };
                double          minX    = p00.GetX();
                double          minY    = p00.GetY();
                double          maxX    = minX;
                double          maxY    = minY;
                foreach (double x in xValues)
                {
                    minX = Math.Min(minX, x);
                    maxX = Math.Max(maxX, x);
                }
                foreach (double y in yValues)
                {
                    minY = Math.Min(minY, y);
                    maxY = Math.Max(maxY, y);
                }
                height = (float)(maxY - minY);
                width  = (float)(maxX - minX);
                pivotY = (float)(p00.GetY() - minY);
                deltaX = -(float)minX;
            }
            // Rotating image can cause fitting into area problems.
            // So let's find scaling coefficient
            // TODO
            float scaleCoeff = 1;

            // hasProperty(Property) checks only properties field, cannot use it
            if (true.Equals(GetPropertyAsBoolean(Property.AUTO_SCALE)))
            {
                scaleCoeff = Math.Min(maxWidth / (float)width, maxHeight / height);
                height    *= scaleCoeff;
                width     *= scaleCoeff;
            }
            else
            {
                if (null != GetPropertyAsBoolean(Property.AUTO_SCALE_WIDTH) && (bool)GetPropertyAsBoolean(Property.AUTO_SCALE_WIDTH
                                                                                                          ))
                {
                    scaleCoeff = maxWidth / (float)width;
                    height    *= scaleCoeff;
                    width      = maxWidth;
                }
                else
                {
                    if (null != GetPropertyAsBoolean(Property.AUTO_SCALE_HEIGHT) && (bool)GetPropertyAsBoolean(Property.AUTO_SCALE_HEIGHT
                                                                                                               ))
                    {
                        scaleCoeff = maxHeight / height;
                        height     = maxHeight;
                        width     *= scaleCoeff;
                    }
                }
            }
            pivotY *= scaleCoeff;
            return(scaleCoeff);
        }
        /// <summary>Construct a unit vector from a given vector</summary>
        /// <param name="vector">input vector</param>
        /// <returns>a vector of length 1, with the same orientation as the original vector</returns>
        private static Point GetUnitVector(Point vector)
        {
            double vectorLength = GetVectorEuclideanNorm(vector);

            return(new Point(vector.GetX() / vectorLength, vector.GetY() / vectorLength));
        }
Beispiel #52
0
        public override Rectangle GetPathShapeRectangle(Point lastPoint)
        {
            Point firstControlPoint = GetFirstControlPoint();
            Point lastControlPoint  = GetLastControlPoint();
            Point endingPoint       = GetEndingPoint();

            double[] points = GetBezierMinMaxPoints(lastPoint.GetX(), lastPoint.GetY(), firstControlPoint.GetX(), firstControlPoint
                                                    .GetY(), lastControlPoint.GetX(), lastControlPoint.GetY(), endingPoint.GetX(), endingPoint.GetY());
            return(new Rectangle((float)CssUtils.ConvertPxToPts(points[0]), (float)CssUtils.ConvertPxToPts(points[1]),
                                 (float)CssUtils.ConvertPxToPts(points[2] - points[0]), (float)CssUtils.ConvertPxToPts(points[3] - points
                                                                                                                       [1])));
        }
 /// <summary>Returns whether a given point lies on a line-segment specified by start and end point</summary>
 /// <param name="segStart">start of the line segment</param>
 /// <param name="segEnd">end of the line segment</param>
 /// <param name="point">query point</param>
 private static bool LiesOnSegment(Point segStart, Point segEnd, Point point)
 {
     return(point.GetX() >= Math.Min(segStart.GetX(), segEnd.GetX()) && point.GetX() <= Math.Max(segStart.GetX(
                                                                                                     ), segEnd.GetX()) && point.GetY() >= Math.Min(segStart.GetY(), segEnd.GetY()) && point.GetY() <= Math.
            Max(segStart.GetY(), segEnd.GetY()));
 }