Bearing calculation out of 2 nmea strings


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default Re: Bearing calculation out of 2 nmea strings

    Sounds like a fine approach to me. The more complicated stuff is for if you want to know which direction and distance it is to something. If you just want to see if its been moved, and don't care which direction it's been moved to, it seems nice and simple.

  2. #2
    Join Date
    Aug 2003
    Posts
    985

    Default Re: Bearing calculation out of 2 nmea strings

    You should be able to cycle a list of waypoints,
    measure the distance to all of them,
    find the closest, calculate the bearing, and draw an arrow pointing to it.
    Was that the idea?

    I finally got PBP working with MPLab again today,
    The trig functions should be fine to rotate points around a screen
    (2D screen with X - Y coordinates) yes ?

    This is how I'd rotate points about an origin in C, where 160x240 is the origin
    this was to connect the points for a 3D cube, so has a faked z axis as well:
    Code:
        // do pre-calculations for rotation
            theta = rotation;		// pre calculations
    	thetab = 360 - theta;
    	thetab = (3.141592 / 180) * theta;
    	ztheta = rotationz;
    	zthetab = 360 - ztheta;
    	zthetab = (3.141592 / 180) * ztheta;    
        
        
    	for(cnt=0; cnt<8; cnt++) {	// 3D rotate points
            xx = xpoints[cnt];
            yy = ypoints[cnt];
            x = xx - 160;
            y = yy - 240;
            xnew = cos(thetab)*x - sin(thetab)*y;
            ynew = sin(thetab)*x + cos(thetab)*y;
            xnew = xnew + 160;
            ynew = ynew + 240;
            if (cnt < 4) {zxx = 160 + 76;} else {zxx = 160 - 76;}
            zyy = ynew;
            zx = zxx - 160;
            zy = zyy - 240;
            zxnew = cos(zthetab)*zx - sin(zthetab)*zy;
            zynew = sin(zthetab)*zx + cos(zthetab)*zy;
            zxnew = zxnew + 160;
            zynew = zynew + 240;
            xcoords[cnt+1] = xnew;
            ycoords[cnt+1] = zynew;
    	}
    The source and return data is coordinate integers, but it appears the trick you do
    is multiplying out the fractions in the formula is to occupy integers and divide later?
    Last edited by Art; - 5th October 2013 at 09:17.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: Bearing calculation out of 2 nmea strings

    Art, I see you're catching up on some reading.

    The last post was from August, 2 years ago.

    Robert (being a smart-azz)

  4. #4
    Join Date
    Aug 2003
    Posts
    985

    Default Re: Bearing calculation out of 2 nmea strings

    It's cool, cordic trig would still be a good thing to get working.
    I tried last time, and had no luck, but it's worth another shot.

    Quote Originally Posted by Demon View Post
    Art, I see you're catching up on some reading.

    The last post was from August, 2 years ago.

    Robert (being a smart-azz)

  5. #5
    Join Date
    Aug 2003
    Posts
    985

    Default Re: Bearing calculation out of 2 nmea strings

    double post :O

Similar Threads

  1. GPS decoding problems
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 25th February 2012, 10:57
  2. Replies: 1
    Last Post: - 26th June 2009, 23:33
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Replies: 20
    Last Post: - 13th May 2007, 05:10
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts