Results 1 to 5 of 5

Thread: need help with rs_compass

  1. #1
    Join Date
    Jul 2008
    Location
    US
    Posts
    104
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default need help with rs_compass

    Okay I got bored and made this little procedure that acts like GetWallAngle(blah) but does the same effect with two Tpoints.

    I have all the angles and junk figured out. even how much to move the mini map.

    But how could I move the compass, let's say 90 degrees?

    Here's how I'm find the angle to change:

    SCAR Code:
    Degrees(ArcTan(TTP.X-TTp.Y/BTM.X-BTM.Y))

    I wouldn't have to convert that bank into radians would I?

    I'll post the whole thing if anyone wants me too

  2. #2
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Whole thing would probably help more, and for once not sure if ill be able to help you out, im a bit confused

  3. #3
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

  4. #4
    Join Date
    Jul 2008
    Location
    US
    Posts
    104
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ha. Okay. lets say you wanted to be lined up perfectly with 2 spots on the mini map. well, you could make a DTM of each Spot. Then Find a Tpoint for each of the DTM's;

    By making a line with those two Tpoints, you can find the angle of the line. Then make the compass vertically lined up, related to those two spots.

    here's some pictures for a rough example. I need to get photoshop lol.

    I couldn't ever get them to upload in pic form, so i had to winrar them. i hope you have it. virus free. If you virus scan them, its not gonna hurt my feelings. lol.

    Attachment 8530


    Instead of using makeCompass('n'), which is never the same, you could use this, so lets say your radial walking is like super accurate every time. oh by the way, I didn't just need this. I just got bored, and made it lol. That's about it. I've tested the math of it. seems to be working okay. The actual degrees to moveCompass, im not to sure about.

    Heres the Procedure:

    SCAR Code:
    //*********************************************************************
    // Uses Trig Functions to find the angle bewtween
    // two Tpoints, and makes compass move
    // so the two tpoints would be vertical with one tpoint being on top.
    // tpoints must be created with FindColor,
    // FindBitmap, FindDTM, ect.
    //
    //*********************************************************************
    var tp1,tp2:tpoint;


    Procedure MoveCompassTrig(TopTP,BottomTP: Tpoint);
    var TTP,BTP:Tpoint;
        beginangle, SLOPE:integer;
    Begin
      TTP   := TopTp;
      BTP   := BottomTP;
      //This Takes care of the (divide by 0) error. refrence: vertical slope
      If  TTP.X = BTP.X Then
      Begin
        If TTP.y > BTP.y Then
        Begin
          WriteLn('Compass already set related to TPoints Set');
          Exit;
        End Else;
        Begin
          //MoveCompass( 180 );
          Exit;
        End;
      End;
      SLOPE := (TTP.Y-BTP.Y/TTP.X-BTP.X);
      BeginAngle := Abs((ROUND(Degrees(ArcTan(SLOPE))))); //changes slope to angle threw opposite of tangent
      WriteLn('Angle=' + IntToStr(BeginAngle));
      WriteLn('Slope=' + IntToStr(TTP.Y-BTP.Y) + '/' + IntToStr(TTP.Y-BTP.Y));

      //if positive slope
      IF (Slope>0) Then
      Begin
        If  TTP.Y > MMCY Then
        Begin
          //MoveCompass(-1 * (90-BeginAngle));
          Exit;
        End Else
        Begin
          //Movecompass( BeginAngle + 90);
          Exit;
        End;
      End;
      //negative slope
      If (Slope < 0) Then
      Begin
        If (TTP.Y > MMCY) Then
        Begin
          //MoveCompass(90-beginangle);
          Exit;
        End Else
        Begin
          //MoveCompass(-1 * (90+ BeginAngle));
          Exit;
        End;
      End;
      //horizontal slope
      If (Slope=0) then
      Begin
        If (TTP.X > BTP.X) Then
        Begin
          //MoveCompass( -90);
          Exit;
        End Else
        Begin
          //MoveCompass(90);
          Exit;
        end;
      End;
    End;


    All of the [//MoveCompass(blah);]'s are just space takers, and notes to myself, about how much to move the compass. ignore them.. and its a bit sloppy right now

    Makecompass(90);?
    okay so would this work

    SCAR Code:
    StartAngle := (rs_GetCompassAngleDegrees);
    //later on in script, example only
    MakeCompass((90-BeginAngle)+StartAngle)
    Last edited by reddevil12312; 10-11-2009 at 08:53 AM.

  5. #5
    Join Date
    Jul 2008
    Location
    US
    Posts
    104
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay can anyone help me with the angle finding??

    I can't figure out a way to manipulate it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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