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

1. 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. 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.