Results 1 to 4 of 4
 05242014, 04:11 AM #1Member
 Join Date
 May 2014
 Posts
 8
 Rep Power
 0
Is this random coordinate inside of the triangle?
 05242014, 04:25 AM #2Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,036
 Rep Power
 6
Re: Is this random coordinate inside of the triangle?
Well, we don't provide code here (except to illustrate general concepts). To solve your problem you first need to figure out how you would do it on paper. You clearly know the height and the width of the triangle. So all you need to worry about is whether it is below the hypotenuse and above the base. So x should be easy. Once you have x, then think about the equation of a straight line to determine y. Once you figure it out on paper, it should be trivial to translate into Java.
Note: The approach above assumes at least one of the two shorter sides is parallel to the xaxis.
Regards,
JimLast edited by jim829; 05242014 at 04:39 AM.
The Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 05242014, 04:31 AM #3Member
 Join Date
 May 2014
 Posts
 8
 Rep Power
 0
 05242014, 04:40 AM #4Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,036
 Rep Power
 6
Re: Is this random coordinate inside of the triangle?
You're welcome. And once you try and code it in Java, we can certainly help you with any syntactic or even logic problems you may encounter.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads

coordinate converter
By footballxpaul in forum New To JavaReplies: 15Last Post: 03202014, 09:03 PM 
I want to color text inside multiple JTextFields located inside JTable
By orbit_balot in forum AWT / SwingReplies: 1Last Post: 06142013, 05:00 PM 
need some urgent help for drawing random points inside a rectangle
By pranav21_1983 in forum Java AppletsReplies: 2Last Post: 04102010, 07:35 PM 
Convert Cartesian coordinate system into java coordinate system?
By 123 in forum Java 2DReplies: 3Last Post: 02072010, 09:34 PM 
Random Points inside a Polygon
By nidhirastogi in forum Advanced JavaReplies: 1Last Post: 09232008, 04:28 AM
Bookmarks