Exemple #1
0
    public Vector2 ConvertToPlanetPos(Vector2 wPos)
    {
        Vector2    pos      = wPos - mPos;
        PolarCoord polarPos = PolarCoord.FromVector(pos);

        return(new Vector2((polarPos.theta / PolarCoord.PI_2) * surfaceLength, polarPos.r - radius));
    }
Exemple #2
0
 public Vector2 ConvertToWorldPos(Vector2 planetPos)
 {
     //convert to world space
     PolarCoord polarPos = new PolarCoord(planetPos.y + radius, (planetPos.x/surfaceLength)*PolarCoord.PI_2);
     Vector2 planetBodyPos = transform.position;
     return planetBodyPos + polarPos.ToVector2();
 }
 public HoughLine(PolarCoord c) : this(VisionLabPINVOKE.new_HoughLine__SWIG_1(PolarCoord.getCPtr(c)), true)
 {
     if (VisionLabPINVOKE.SWIGPendingException.Pending)
     {
         throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public void PolarToCartesianTest()
        {
            PolarCoord origin = new PolarCoord(3.7416573867739413d, 0.64209261593433065d);
            Coord      target = PolarCoord.PolarToCartesian(origin);

            Assert.AreEqual(new Coord(3, 2), target);
        }
    public PolarCoord ToPolarCoord()
    {
        PolarCoord p = new PolarCoord();

        p.Radius = Math.Sqrt(X * X + Y * Y);
        p.Angle  = Math.Atan(Y / X);
        return(p);
    }
Exemple #6
0
    public Vector2 ConvertToWorldPos(Vector2 planetPos)
    {
        //convert to world space
        PolarCoord polarPos      = new PolarCoord(planetPos.y + radius, (planetPos.x / surfaceLength) * PolarCoord.PI_2);
        Vector2    planetBodyPos = transform.position;

        return(planetBodyPos + polarPos.ToVector2());
    }
Exemple #7
0
    public bool SmallerThan(PolarCoord arg0)
    {
        bool ret = VisionLabPINVOKE.PolarCoord_SmallerThan(swigCPtr, PolarCoord.getCPtr(arg0));

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
        public void PolarCoordTest()
        {
            PolarCoord target     = PolarCoord.CartesianToPolar(new Coord(5, 5));
            PolarCoord origin     = new PolarCoord(7.0710678118654755f, 0.64209261593433065f);
            Coord      cartTarget = PolarCoord.PolarToCartesian(target);
            Coord      cartOrigin = PolarCoord.PolarToCartesian(origin);

            Assert.AreEqual(target, origin);
            Assert.AreEqual(cartTarget, cartOrigin);
        }
Exemple #9
0
    public bool Not(PolarCoord c)
    {
        bool ret = VisionLabPINVOKE.PolarCoord_Not(swigCPtr, PolarCoord.getCPtr(c));

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
 // Use this for initialization
 void Start()
 {
     _animator = GetComponent <Animator>();
     _sounds   = new List <AudioClip> {
         chop1, chop2, chop3
     };
     _poctoscript    = GetComponent <Poctoscript>();
     _spriteRenderer = GetComponent <SpriteRenderer>();
     _defaultniStrom = _spriteRenderer.sprite;
     PolarStromu     = new CartesianCoord(transform.position.x, transform.position.y).ToPolar();
 }
        public void CartesianToPolarTest()
        {
            Coord      origin         = new Coord(5, 5);
            PolarCoord target         = PolarCoord.CartesianToPolar(origin);
            double     expectedRadius = Math.Sqrt(50);
            double     expectedTheta  = 1 / Math.Tan(1);


            Assert.Less(expectedTheta - 0.01, target.Theta);
            Assert.Greater(expectedTheta + 0.01, target.Theta);
            Assert.Less(expectedRadius - 0.01, target.Radius);
            Assert.Greater(expectedRadius + 0.01, target.Radius);
        }
Exemple #12
0
    private void Start()
    {
        // postava zacina na brane krom poprve (pro tutorial)
        if (branoTransform && !GameState.Instance.RunTutorial)
        {
            var cartesianBrano = new CartesianCoord(branoTransform.transform.localPosition.x,
                                                    branoTransform.transform.localPosition.y);
            PolarCoord = new PolarCoord(cartesianBrano.ToPolar().R, cartesianBrano.ToPolar().Phi);
        }
        else
        {
            PolarCoord = new PolarCoord(1, Radius);
        }

        _anim      = GetComponent <Animator>();
        _renderer  = GetComponent <SpriteRenderer>();
        origCamera = Camera.main.transform;
    }
 public bool SmallerThan(PolarCoord arg0) {
   bool ret = VisionLabPINVOKE.PolarCoord_SmallerThan(swigCPtr, PolarCoord.getCPtr(arg0));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
    void LateUpdate()
    {
        float dt = Time.deltaTime;

        Vector3 _planetPos = planet.transform.position;

        //orient to planet
        if(applyOrientation) {
            Vector2 mDirToPlanet = _planetPos - mTrans.position;
            mDirToPlanet.Normalize();

            Quaternion q = Quaternion.FromToRotation(mTrans.up, -mDirToPlanet);
            mTrans.rotation = q * mTrans.rotation;
        }

        if(!mIsGround && applyGravity) {
            mYVel += planet.gravity*dt;

            if(mYVel > maxYVelCap) {
                mYVel = maxYVelCap;
            }
        }

        if(accel != Vector2.zero) {
            velocity += accel*Time.deltaTime;
        }

        if(maxVelocity > 0) {
            if(velocity.y == 0 && velocity.x > maxVelocity) {
                velocity.x = maxVelocity;
            }
            else if(velocity.sqrMagnitude > mMaxVelocitySq) {
                velocity.Normalize();
                velocity *= maxVelocity;
            }
        }

        if(velocity != Vector2.zero || mYVel != 0) {
            planetPos += new Vector2(velocity.x*dt, (velocity.y+mYVel)*dt);
        }

        //convert to world space
        PolarCoord polarPos = new PolarCoord(planetPos.y + planet.radius, (planetPos.x/planet.surfaceLength)*PolarCoord.PI_2);

        Vector3 pos = mTrans.position;
        Vector3 nPos = _planetPos + polarPos.ToVector3(); nPos.z = pos.z;
        mTrans.position = nPos;
    }
Exemple #15
0
 internal static HandleRef getCPtr(PolarCoord obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
 public static string PolarCoordToStr(PolarCoord polar) {
   string ret = VisionLabPINVOKE.PolarCoordToStr(PolarCoord.getCPtr(polar));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public static PolarCoord StrToPolarCoord(string str) {
   PolarCoord ret = new PolarCoord(VisionLabPINVOKE.StrToPolarCoord(str), true);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Exemple #18
0
 public PointF Point(float degree, float radius)
 {
     return(PolarCoord.Create(degree, size * radius).CarthesianCoord.Offset(origin));
 }
 public static Coord2D PolarLinesIntersection(PolarCoord pc1, PolarCoord pc2) {
   Coord2D ret = new Coord2D(VisionLabPINVOKE.PolarLinesIntersection(PolarCoord.getCPtr(pc1), PolarCoord.getCPtr(pc2)), true);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Exemple #20
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PolarCoord obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
 public bool Not(PolarCoord c) {
   bool ret = VisionLabPINVOKE.PolarCoord_Not(swigCPtr, PolarCoord.getCPtr(c));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 internal static HandleRef getCPtr(PolarCoord obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 public HoughLine(PolarCoord c) : this(VisionLabPINVOKE.new_HoughLine__SWIG_1(PolarCoord.getCPtr(c)), true) {
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
Exemple #24
0
    void LateUpdate()
    {
        float dt = Time.deltaTime;

        Vector3 _planetPos = planet.transform.position;

        //orient to planet
        if (applyOrientation)
        {
            Vector2 mDirToPlanet = _planetPos - mTrans.position;
            mDirToPlanet.Normalize();

            Quaternion q = Quaternion.FromToRotation(mTrans.up, -mDirToPlanet);
            mTrans.rotation = q * mTrans.rotation;
        }

        if (!mIsGround && applyGravity)
        {
            mYVel += planet.gravity * dt;

            if (mYVel > maxYVelCap)
            {
                mYVel = maxYVelCap;
            }
        }

        if (accel != Vector2.zero)
        {
            velocity += accel * Time.deltaTime;
        }

        if (maxVelocity > 0)
        {
            if (velocity.y == 0)
            {
                if (velocity.x > maxVelocity)
                {
                    velocity.x = maxVelocity;
                }
                else if (velocity.x < -maxVelocity)
                {
                    velocity.x = -maxVelocity;
                }
            }
            else if (velocity.sqrMagnitude > mMaxVelocitySq)
            {
                velocity.Normalize();
                velocity *= maxVelocity;
            }
        }

        if (velocity != Vector2.zero || mYVel != 0)
        {
            planetPos += new Vector2(velocity.x * dt, (velocity.y + mYVel) * dt);
        }

        //convert to world space
        PolarCoord polarPos = new PolarCoord(planetPos.y + planet.radius, (planetPos.x / planet.surfaceLength) * PolarCoord.PI_2);

        Vector3 pos  = mTrans.position;
        Vector3 nPos = _planetPos + polarPos.ToVector3(); nPos.z = pos.z;

        mTrans.position = nPos;
    }