Help needed in class. cant figure out distance

i have declared 3 variables in a class, x and y are coordiantres
public class Robot
private double X;
private double Y;
private double Orientation;     
public Robot()
X = 0;
Y = 0;
Orientation = 0;
public (double pX, pY, double pOrientation)
iX = pX;
iY= pY;
iOrientation = pOrientation;
public double getX()
return iXCoordinate;
public double getY()
return iY;
public double getOrientation()
return iOrientation;
public void turnRight (double pDeg) //Degrees
iOrientation= iOrientation + pDeg;
public void moveForward (double pDis)
double d=0;
double dx=0;
double dy=0;
double radians=0;
radians = Math.toRadians(A); //A is converted to radians     
dx=d* Math.sin(radians); //distance travelled in x
dy=d* Math.cos(radians);//distance travelled in y
how do i get the moveforward i have been given the code written above. in the method also been given dx = d*sin(A) and dy = d*cos(A)
aprreciate the help thanks

Damn, I love NetBeans' code reformatting macro...
public void moveForward(double pDis) {
  double d=0;
  double dx=0;
  double dy=0;
  double radians=0;
  radians = Math.toRadians(A); //A is converted to radians
  dx=d* Math.sin(radians); //distance travelled in x
  dy=d* Math.cos(radians);//distance travelled in y
}If you read the comments in this method it quite clearly tells you that it is giving you the distances travelled in both dimensions. All you need to do is add those to the objects current position and voila, you have displacement.
(This is why courses on Newton's laws of motion should be required education for all students)
McF

Similar Messages

  • Help I have a G5 and I need to dowload or upgrade to mac osx 10.5 and i cant figure out how

    Help I have a G5 and I need to dowload or upgrade to mac osx 10.5 and i cant figure out how

    Mac OS X 10.5 Leopard installation system requirements
    http://support.apple.com/kb/TA24950
    Leopard is no longer available at the Apple Store but may be available by calling Apple Phone Sales @ 1-800-MY-APPLE (1-800-692-7753).
    If you can't obtain a retail install DVD from Apple, look on eBay or Google the installer part numbers to possibly find at an on-line store. Here's what to look for:
    MB427Z/A  Leopard 10.5.1 install DVD
    MB576Z/A  Leopard 10.5.4 install DVD
    MB021Z/A  Leopard 10.5.6 install DVD (single user)
    MB022Z/A  Leopard 10.5.6 install DVD (5-user family pack)
    Installing Mac OS X 10.5 Leopard
    http://support.apple.com/kb/HT1544
    Mac OS X 10.5 Leopard Installation and Setup Guide
    http://manuals.info.apple.com/en/leopard_install-setup.pdf
    After you install the base 10.5, download & install the 10.5.8 combo update at http://support.apple.com/downloads/Mac_OS_X_10_5_8_Combo_Update
    The DVD should look like this
    Caution - Leopard does not support classic mode. So, if you currently open OS 9 apps in classic mode, you won't be able to do this if you upgrade to Leopard.
     Cheers, Tom

  • I tried to sinc my photos and i ended up deleting off my phone all the pictures.  i only ended up with one folder, and i cant figure out how to put rest of folders from my computer back on my phone.....help

    i tried to sinc my photos and i ended up deleting off my phone all the pictures.  i only ended up with one folder, and i cant figure out how to put rest of folders from my computer back on my phone.....help
    and on a second problem.  I need to know for sure that my contacts are backed up on my computer

    Create a parent folder on your computer to store the named folders of photos that you want transferred to your iPhone. Under the Photos tab for your iPhone sync preferences with iTunes, select the parent folder. All named folders of photos within will be transferred to your iPhone as separate folders or albums.
    Regarding your 2nd question, this should be easy. Your contacts should be available on your computer with or without an iPhone or any cell phone, which can be lost or stolen.
    Although contacts are included with your iPhone's backup which is updated by iTunes as the first step during the iTunes sync process, not a good idea to depend on this either since the iPhone backup includes a significant amount of other data. Contacts are designed to be synced with a supported address book app on your computer. With Windoze, this can be with Outlook 2003, 2007, or 2010 along with syncing calendar events and notes, or with the address book app used by Outlook Express with XP and by Windows Mail with Vista and Windows 7 called Windows Contacts for syncing contacts only.

  • Help... I cant figure out how to put videos on my ipod?

    well, i got an ipod video for christmas, but i still havent been able to put any videos on it. i haven't figured out how. i've got a few videos downloaded on itunes, but when i try to drag them over to my ipod, it says "selected files ... bla, bla, bla ...these cannot be played on this ipod" or something to that extent. and i also herd that you can rip DVDs to your ipod, but i cant figure out how to do that either. can anyone help me?

    ok listen. forget everything that you've tried to do so far. what you need to do first is download a program called Videora iPod Converter (my recommendation). If you have LimeWire, you can just get it off of there. And if you don't have LimeWire, I'm sorry and I don't know where to get it, but i'm assuming that you can get it off of the videora website.
    ok when you get there, click convert, and after that, there should be a "transcode new video" button on the screen. click that and open the file that you want to rip. and then push start. after it says transcode complete, go to your videora ipod converter folder (which you get when you download the program) and you'll find that file in the folder. double click that file and it should open up with itunes. after its in the library just update your ipod and itll get on there!

  • HT5622 I cant figure out how to authorize my office computer to download songs that I have purchased. A message saying I cant do it, but gives me no link to make it happen. Frustrating.Can someone help?

    I cant figure out how to authorize my office computer to download songs that I have purchased. A message saying I cant do it, but gives me no link to make it happen. Frustrating.Can someone help?

    If you're running iTunes 11 and you don't see the menus, press Control-B or go to the small icon with the arrow at the extreme upper left and select "Show Menu Bar":
    Apple for some inexplicable reason elected to hide the menus by default in the Windows version of iTunes 11.
    I doubt that this will address a download problem, though. You'll need to provide more details about that; what device you're attempting the download on, the exact error message, and other such pertinent information.
    Regards.

  • Can any one help i have lost safari on my powerMAC g4 and cant figure out how to get it back  and safari 5 is not supported on my cumputer

    can any one help i have lost safari on my powerMAC g4 and cant figure out how to get it back  and safari 5 is not supported on my computer

    Make sure there's enough free space on the startup disk.
    Right or control click the MacintoshHD icon on your Desktop.
    Click Get Info. In the Get Info window you will see Capacity and Available.
    Make sure there's a minimum of 15% free disk space.
    If there's sufficient disk space, the startup disk may need repairing.
    Launch Disk Utility located in /Applications/Utilities
    Select the startup disk on the left then select the First Aid tab.
    Click Verify Disk  (not Verify Disk Permissions)
    You will need your install disc if the startup disk needs repairing.
    Using Disk Utility to verify or repair disks

  • I have an ipod touch and i put cds on itunes on my pc , but i cant figure out how to put the music from the cds on my ipod .. can u help me ?

    i have an ipod touch and i put cds on itunes onmy computer , but i cant figure out how to put the music from the cds on my ipod touch can anyone help me?

    ok i select th e music from my music libary and go to file and click sync to my ipod and when it gets to step 3.. it says waiting for changes to be made.. yes the songs play on the itunes ..  and no it wasnt the same computer i used last time

  • My mini died. bought one used from a friend... all of my songs and books are on my iPhone, and I cant figure out how to get them onto this new computer. this is frustrating. the things i really want are purchases I've made from itunes store... help

    My mini died. bought one used from a friend... all of my songs and books are on my iPhone, and I cant figure out how to get them onto this new computer. this is frustrating. the things i really want are purchases I've made from itunes store... help
    !!!!!

    Hey kevyg3,
    I was able to find an article that I believe will help you move your iTunes purchases from your iPhone over to your new computer:
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    http://support.apple.com/kb/HT1848
    Hope this helps,
    David

  • My ipod touch is disabled, i installed the latest version of itunes, but cant figure out how to restore, can anyone help with this?

    My ipod touch is disabled, i installed the latest version of itunes, but cant figure out how to restore the ipod, can anyone help?

    If you run into the "another installation" message even after the reboot of the PC (which is an excellent idea by HTP ProXy), reregistering your Windows Installer Service is worth a try.
    First, launch a command prompt as an administrator. In your Start search, type cmd then right-click on the cmd that comes up and select "Run as administrator".
    At the command prompt:
    Type %windir%\system32\msiexec.exe /unregister and hit enter.
    Type %windir%\syswow64\msiexec.exe /unregister and hit enter.
    Type %windir%\system32\msiexec.exe /regserver and hit enter.
    Type %windir%\syswow64\msiexec.exe /regserver and hit enter.
    Restart the PC and try another reinstalll.

  • Help , i have cds on my laptop and i cant figure out how to put them on my iphone

    help i have cds on my laptop and i cant figure out how to put them on my iphone

    Sync them as described in the User's Guide.

  • HT1311 i sold my iphone and i cant figure out how to unlock it so it can be used.  can anyone help??

    i recently sold my iphone and it is locked so it cannot be used.  cant figure out how to unlock it....can anyone help??

    wilser01 wrote:
    i recently sold my iphone and it is locked so it cannot be used.  cant figure out how to unlock it....can anyone help??
    Did you erase it before you sold it?
    Settings> General > Reset - Erase all content & settings.
    Or did you leave all your personal info on it and give it to someone else?

  • New to logic and i cant figure out how to dupe a mono single to stereo?help

    So I'm loving logic but im used to working on adobe audition and i cant figure out for the life of me how to take the mono loop im working with and turn it in to stereo. Please help and thanks ahead of time.

    You can use a mono to stereo plugin. Spreader would be a good choice.

  • I just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    i just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    Did you enable Siri in settings?
    Settings > General > Siri > ON
    If Siri is off, all you get when pressing the home button for 1 second is the old Voice Control.

  • HT1351 Got a used 4th gen nano, but i need to sync it. i can see it but i cant figure out how to authorize it

    Got a used 4th gen nano and I need to sync it with my library on my computer. I can see the ipod but i cant figure out how to authorize it

    You don't need to "authorize" it, unless you are trying to sync content that uses DRM (copy protection).  You probably just need to set up syncing.
    First, if the iTunes sidebar (along left side of window) is hidden, from the menu bar, under View, select Show Sidebar.  The iPod appears in the sidebar, under DEVICES, when connected.
    Select the iPod in the sidebar.  The iPod's Summary screen is shown to the right.  Toward the top, there is a bar of buttons, starting with Summary.  Click on Music to the right of Summary.  This Music screen is where you tell iTunes how to sync songs to the iPod.
    Check the box for Sync Music.  If your iTunes music library is small enough to fit on the iPop's storage, you can choose to sync Entire music library.  Otherwise, choose to sync Selected playlists, artists, albums, and genres.  From the lists below, select what you want to sync the iPod.  One convenient way to set this up is to create one or more playlists in your iTunes library, and put ALL of the songs you want on the iPod on those playlists.  (Or you can use existing playlists.)  Back on the iPod's Music screen, select (checkmark) those playlists under Playlists.  You can also select other items on those lists, as desired.
    When you click Apply, iTunes syncs the songs in your selections to the iPod.  Going forward, to update the iPod, just update those playlists in your iTunes library (add/remove songs).  The iPod does not need to be connected.  The next time you connect the iPod (or click Sync if already connected), iTunes updates the iPod with the same changes automatically.

  • I connected to itunes and it says i have 2.11 GB of space taken up under OTHER , i cant figure out what is taking up so much space can anyone help?

    i connected to itunes and it says i have 2.11 GB of space taken up under OTHER , i cant figure out what is taking up so much space can anyone help?

    I believe the new IOS 8 system takes up 1.3 Gb on it's own.   Then plus anything else you may have loaded.

Maybe you are looking for

  • Ipod touch doesn't sync to itunes? it goes to  Picassa (a camera photo software). Ive deleted picassa from computer. what next?

    new ipod touch not syncing to itunes. nothing happening. I think Picassa on my computer picked it up! i deleted that program. what next?

  • How to update to Camera Raw 7.4

    I just don't get it how to do this ... Will you please impart your knowledge. I so thank you. Penni

  • Org Data Determination in Opportunity

    Dear All, While Opportunity Creation, after entering the sales prospect, contact person and employee responsible and Organizational data have to be determined automatically. To achieve this what configuration settings I have to make in SPRO. Please e

  • Gnome trouble

    I can't log into gnome. I use GDM, followed the wiki. 1) I the get "your session has only lasted less than 10 seconds" error and when I look at more details it says: error while loading shared libraries libgnutls.so:12 (or something very similar) # l

  • Grass valley k2 solo

    Hello i am new to media encoder and I am trying to transcode media files from an apple computer a .mov file and a file from a windows pc a .wmv file on to a grass valley K2 solo. The grass valley K2 solo works with DVC PRO 100 or AVC I CLASS 100 4.2.