Bearing calculation out of 2 nmea strings


Results 1 to 10 of 10

Threaded View

  1. #7
    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 10:17.

Similar Threads

  1. GPS decoding problems
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 25th February 2012, 11:57
  2. Replies: 1
    Last Post: - 27th June 2009, 00:33
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36
  4. Replies: 20
    Last Post: - 13th May 2007, 06:10
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18: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