Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Coordinates

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Coordinates

    I am in an intro level programming class which uses Java (along with BlueJ).

    Today we had to manipulate a line in the Java coordinate plane (sorry, I don't know the jargon).

    Everything was going fine until I had to figure out the slope of the line. Due to the way the Java coordinates are laid out - (0,0) in the top left corner with values increasing to the bottom right corner - the slope worked the opposite as expected (specifically the 'y' or 'rise' value).

    I ended up getting this right. As I view it, we are working in Quadrant 4 of a Cartesian plane, so I had to negate the run value: (It looked something like: int run = -(y2-y1)).

    In some part, I understand this, but I am also having a difficult time visualizing this fully. Can anyone help me visualize this a bit more?

    I know this is a tad vague, but I really am at a loss for how to fully explain my confusion (which is no doubt part of the confusion).


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Java Coordinates

    This is how I think about it: you've got a model and a view. The model represents...well the model - in your case, a line from point A to point B in your coordinate space. The view displays what the model represents. The way in which you described, it seems you are taking the model, placing it in the view, then extrapolating properties of the model from the view. Another way is to extrapolate the properties (slope) of the model directly from the model rather than indirectly through the view. This is an example of a pattern in programming termed MVC (model-view-controller). The view displays the model, any properties you wish to gather is done so directly through the model, and to take the concept one step further the controller (C) extrapolates interaction from the view to change the model.

Similar Threads

  1. How to set random X,Y coordinates within a TRIANGLE?
    By r3dApple in forum Java Theory & Questions
    Replies: 1
    Last Post: February 5th, 2012, 08:12 AM
  2. Help with plotting x-y coordinates.
    By mixmagz in forum Object Oriented Programming
    Replies: 5
    Last Post: January 23rd, 2012, 09:41 AM
  3. Mapping real coordinates into GUI
    By gloor in forum AWT / Java Swing
    Replies: 2
    Last Post: May 26th, 2011, 08:35 AM
  4. Java graphic coordinates out of bounds?
    By jnmcneel in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 24th, 2011, 03:28 PM
  5. Retrieve coordinates of other windows
    By Knox in forum AWT / Java Swing
    Replies: 1
    Last Post: April 10th, 2011, 02:03 PM