dy = 0 + velocity * timeValue - (1 / 2) * RATE_OF_ACCELERATION * (Math.pow(timeValue, 2));Edited: Added the line where it occurs to avoid confusion and sound less smug. :\

This post has been edited by **Sheph**: 07 December 2011 - 06:11 PM

Posted 07 December 2011 - 06:02 PM

What is (1 / 2) when you divide two integers? I'm pretty sure it's 0.

dy = 0 + velocity * timeValue - (1 / 2) * RATE_OF_ACCELERATION * (Math.pow(timeValue, 2));Edited: Added the line where it occurs to avoid confusion and sound less smug. :\

This post has been edited by **Sheph**: 07 December 2011 - 06:11 PM

Posted 07 December 2011 - 06:08 PM

On another note. I was testing your class. It took me a while to find that mistake actually. You might consider setting it's position to 0 and stopping the timer when it reaches a certain point so it doesn't go off the screen. Maybe a button that resets the ball for your viewing pleasure

Posted 07 December 2011 - 06:24 PM

The ball seems to speed up kind of "weirdly". And how would I make it curve?

Posted 07 December 2011 - 06:32 PM

The reason it isn't curving is because you eliminate gravity from the equation by multiplying it by (1/2). In java 1 is an integer, and 2 is an integer, and 1 / 2 = 0.5, but it must be converted to an integer, which truncates the decimal value, making it 0 (an integer).

So your ball is really just being drawn on the timeline with a slope of -1. To fix this, try changing your 1/2 to 0.5, so it recognizes it at a double, or do

velocity * timeValue - ( ( RATE_OF_ACCELERATION/2 ) * Math.pow(timeValue,2) )

dy = 0 + velocity * timeValue - (1 / 2) * RATE_OF_ACCELERATION * (Math.pow(timeValue, 2)); //simplified dy = 1 * timeValue - ( 0 * -9.8 * Math.pow(timeValue,2) ); // this last part equates to 0. dy = timeValue; // same as your x.

So your ball is really just being drawn on the timeline with a slope of -1. To fix this, try changing your 1/2 to 0.5, so it recognizes it at a double, or do

velocity * timeValue - ( ( RATE_OF_ACCELERATION/2 ) * Math.pow(timeValue,2) )

This post has been edited by **Sheph**: 07 December 2011 - 06:34 PM

Posted 07 December 2011 - 06:36 PM

Couldn't you write

(1D / 2D)?

Posted 07 December 2011 - 06:45 PM

Okay. I seem to have fixed the curve problem. My next objective is to make it bounce. How do I go about that?

Posted 07 December 2011 - 07:00 PM

After each movement, you could check if you are above or below the bottom of the screen. If your above - keep going. If your below, you can set the balls position back to the bottom of the screen. At that point you use the same formulas again, but with a reduced velocity. (using the new balls position as 0,0) You would have to add the new balls start position from the left edge of the screen to each new location of the ball in motion.

I'm not sure about walls though - I'd image you just invert the x direction (and reduce velocities if you want to).

I might try my own implementation of this, I have decided after reading this thread to study physics aswell, I haven't taken a physics class myself, so good to learn =)

I'm not sure about walls though - I'd image you just invert the x direction (and reduce velocities if you want to).

I might try my own implementation of this, I have decided after reading this thread to study physics aswell, I haven't taken a physics class myself, so good to learn =)

This post has been edited by **Mylo**: 07 December 2011 - 07:01 PM

Posted 07 December 2011 - 08:46 PM

Well bouncing the ball is a little more complicated. First you have to determine where the ball is going to bounce. You can say the bottom of your screen. Then when the ball goes out of the bottom of your screen, you have to set it's position to the bottom of your screen, or maybe even find the displacement from the bottom of the screen and draw it up that many pixels ... ANYWAY

So you reset it's position, meaning that it's initial position (y0) has changed. The time is also reset, because it has started a new falling cycle relative to a new starting position. Lastly, you must change the initial velocity as well. It becomes the vector of the velocity when it hit the ground , but reflected across the x-axis. In other words, you have to derive the velocity from your position formula. That requires some calculus, so let me do that for you:

Lastly, if you want to simulate REAL bouncing, you have to account for some friction and elasticity. This involves physics. Meaning, you should reduce the MAGNITUDE (absolute value) of the velocity by an amount each time it bounces. You could probably get away with reducing it by a fixed amount each time, like 20%.

So you reset it's position, meaning that it's initial position (y0) has changed. The time is also reset, because it has started a new falling cycle relative to a new starting position. Lastly, you must change the initial velocity as well. It becomes the vector of the velocity when it hit the ground , but reflected across the x-axis. In other words, you have to derive the velocity from your position formula. That requires some calculus, so let me do that for you:

y0 + yVelocity*t + (g/2)*t^2 where g = -9.8 m/s^2, derived is: yVelocity + g*t Then you have to reflect the value across the x-axis (-y) -(yVelocity + g*t)This is your new yVelocity. Your new y0 is where you set the ball. Then the formula recalculates the rest for you.

Lastly, if you want to simulate REAL bouncing, you have to account for some friction and elasticity. This involves physics. Meaning, you should reduce the MAGNITUDE (absolute value) of the velocity by an amount each time it bounces. You could probably get away with reducing it by a fixed amount each time, like 20%.

This post has been edited by **Sheph**: 07 December 2011 - 08:48 PM

Posted 07 December 2011 - 09:10 PM

Okay... Maybe physics is a little too hard for me right now. What I really want to know how to do is have an image with cubes in it, then, based on the color of the cubes in the image, it will draw different shapes on the screen. Will the physics or the image thing be harder?

Posted 08 December 2011 - 02:31 AM

I would like to point out that there are lots of physics libraries written for every language. I haven't studied lots of physics so if I'm ever going to make a game, rather than using my time learning, I'll use an existing library for the physics. This will save my time and the physics will most likely be tested already by many developers so it won't have that many bugs.

e. tons of typos removed

e. tons of typos removed

This post has been edited by **janne_panne**: 09 December 2011 - 01:56 AM

Posted 08 December 2011 - 10:32 AM

I 100% agree with janne_panne here. It's one thing to discuss one aspect of physics, like gravity. It's another thing to start writing an entire physics engine in a help thread.

Because now you're not just talking about a simple acceleration applied over time, you're talking about mass, force, elasticity, angles of incidence, etc...It gets exponentially more complicated the more features you're looking for.

I've heard lots of good stuff about Box2D, and there's a java implementation:

http://www.jbox2d.org/

Maybe that'll help.

Because now you're not just talking about a simple acceleration applied over time, you're talking about mass, force, elasticity, angles of incidence, etc...It gets exponentially more complicated the more features you're looking for.

I've heard lots of good stuff about Box2D, and there's a java implementation:

http://www.jbox2d.org/

Maybe that'll help.

Posted 08 December 2011 - 11:15 AM

Also, while a lot of physics can be abstracted to precalculus and trig, dealing with more physics requires at least a basic understanding of calculus. The more physics you want, the more calculus you'll need. Take a physics class in high school once you get more math under your belt as well. Don't try and re-create a physics engine though.

Posted 08 December 2011 - 11:37 AM

Lol. Okay. But do any of you know how to make it so you can import an image which is a grid filled with different colored squares and based on those colors you could print images on a JPanel in the same grid arrangment but instead of the colored squares you could have images?

Posted 08 December 2011 - 11:48 AM

I'll post what I have to do in math today if that helps for anything.

Spoiler

Examining Inequalities in Two Triangles

Robotic arms are used in a variety of industries to complete various tasks. For example, robotic arms are often used in the automotive industry for welding or completing other assembly line tasks. Robotic arms have also been used for work on space shuttles. The photographs show robotic arms in two different positions. In which position is the end of the robotic arm closer to the base?

In this lesson, you will learn how to prove the answer to this question by applying inequality relationships between angles and sides in two triangles.

Objective

Apply inequalities in two triangles

Objectives derived from Pearson Education programs © Pearson Education, Inc., or its affiliates. All rights reserved.

Tip: You will have two days to complete this lesson.

----------------------------

Relationships in Triangles

Click on the link below to complete the Solve It! for Chapter 5, Lesson 7 from the PowerAlgebra website.

Solve It!

Click on the link below to watch the "Inequalities in Two Triangles” Teachlet® tutorial. As you view the tutorial, review the lesson objectives and be sure that you are comfortable with the concepts presented before continuing with the lesson..

Inequalities in Two Triangles

Read pp. 332–335 in Geometry. Take note of the Hinge Theorem on p. 332 and its converse on p. 334.

Tip: Recall that an included angle in a triangle is formed by two sides of a triangle and therefore is located between the two sides.

Click on the link below to access the online textbook.

Geometry

------------------------------

Complete the following activities.

Recall the robotic arm problem from the beginning of this lesson. The diagrams to the right show the triangles formed by robotic arms in two different positions. In which position is the end of the robotic arm closer to the base? Explain your reasoning.

Write the Hinge Theorem and its converse as a biconditional.

Click on the Show Answer button below to check your answers.

Answers:

The end of the robotic arm with the 40o angle is closer to the base. The lengths of the two sections of the robotic arm do not change as the arm moves, but the included angle changes. By the Hinge Theorem, the triangle with the larger included angle is opposite the longer side of the triangle.

Two sides of one triangle are congruent to two sides of another triangle, and the included angles are not congruent if and only if the longer third side is opposite the larger included angle.

or

Two sides of one triangle are congruent to two sides of another triangle, and the third sides are not congruent if and only if the larger included angle is opposite the longer third side.

Complete problems 7, 9, 11, 13, 15, 19, 21, and 23 starting on p. 336 in Geometry.

Click on the link below to complete the 5-7 Enrichment activity.

5-7 Enrichment

When you have finished, click on the link below to check your answers to the 5-7 Enrichment.

Answers

Click on the link below to access the online textbook.

Geometry

Extension: Click on the link below view the "Using Inequalities Involving Angles of Triangles" and "Using Inequalities Involving Sides of Triangles" Homework Video Tutors for Chapter 5, Lesson 6 from the PowerGeometry website.

Using Inequalities Involving Angles of Triangles

Using Inequalities Involving Sides of Triangles

---------------------------------

Complete the following review activities.

In this lesson, you learned about inequalities in two triangles using the Hinge Theorem and its converse. Be sure you understand how to use the Triangle Inequality Theorems and can apply the concepts to solve problems involving triangles that have two pairs of congruent sides. At the end of this lesson is a quiz covering the lessons listed below. The activities that follow will provide review practice of the concepts in order to prepare for the quiz.

Lesson 4 – Medians and Altitudes

Lesson 5 – Inequalities in One Triangle

Lesson 6 – Inequalities in Two Triangles

Complete the Lesson Check on p. 336 of Geometry.

Complete Got It? for problems 1–5 starting on p. 325 of Geometry.

Click on the link below to complete the Self-Assessment 5-4 activity from the PowerGeometry website.

Self-Assessment 5-4

Click on the link below to access the online textbook.

Geometry

----------------------------------------

Inequalities in Two Triangles

Kenneth Clark is taking this assessment.

Multiple Choice

1. In ABC, centroid D is on median . AD = x + 5 and DM = 2x – 1. Find AM.

(1 point)

11

5

12

2. Where can the lines containing the altitudes of an obtuse triangle intersect?

I. inside the triangle

II. on the triangle

III. outside the triangle (1 point)I only

I or II only

III only

I, II, or III

3. Where can the medians of a triangle intersect?

I. inside the triangle

II. on the triangle

III. outside the triangle (1 point)I only

III only

I or III only

I, II, or III

4. Which labeled angle has the greatest measure? The diagram is not to scale.

(1 point)

There is not enough information in the diagram.

5. Name the smallest angle of ABC. The diagram is not to scale.

(1 point)C

A

Two angles are the same size and smaller than the third.

B

6. Three security cameras were mounted at the corners of a triangular parking lot. Camera 1 was 151 ft from camera 2, which was 122 ft from camera 3. Cameras 1 and 3 were 139 ft apart. Which camera had to cover the greatest angle? (1 point)camera 1

camera 2

camera 3

There is not enough information to tell.

7. List the sides in order from shortest to longest. The diagram is not to scale.

(1 point)

8. Which three lengths CANNOT be the lengths of the sides of a triangle? (1 point)25 m, 16 m, 10 m

15 m, 13 m, 12 m

18 m, 5 m, 10 m

8 m, 8 m, 15 m

9. Which of the following must be true? The diagram is not to scale.

(1 point)BC < FH

AC = FH

AB < BC

AC < FH

10. If mDBC = 65°, what is the relationship between AD and CD?

(1 point)AD > CD

There is not enough information to tell.

AD < CD

AD = CD

Short Answer

Note: Remember to show all of the steps that you use to solve the problem. You can use the comments field to explain your work. Your teacher will review each step of your response to ensure you receive proper credit for your answer.

11. What is the orthocenter of the triangle with two altitudes given by the lines x = –1 and y = x + 1?

(2 points)

12. What is the range of possible values for x? The diagram is not to scale.

(2 points)

13. What are the missing reasons in the two-column proof?

Given:JM = ML and mJMK > mKML

Prove: JK > KL

Statements Reasons

1. JM = ML 1. Given

2. KM = KM 2. __?__

3. mJMK > mKML 3. Given

4. JK > KL 4. __?__

(2 points)

14. Two sides of a triangle have lengths 11 and 18. Write an inequality to represent the possible lengths for the third side, x. (2 points)

15. Find the length of , given that is a median of the triangle and AC = 50.

(2 points)

16. You have two pieces of wood that will make up two sides of a triangular picture frame. One is 6 in. long and the other is 7 in. long. What is the range of the possible lengths for the third side of the frame? (2 points)

17. Given ΔDEF with D(–4, –1), E(–1, 8), and F(5, 4), find the median DT in point-slope form. (2 points)

Examining Inequalities in Two Triangles

Robotic arms are used in a variety of industries to complete various tasks. For example, robotic arms are often used in the automotive industry for welding or completing other assembly line tasks. Robotic arms have also been used for work on space shuttles. The photographs show robotic arms in two different positions. In which position is the end of the robotic arm closer to the base?

In this lesson, you will learn how to prove the answer to this question by applying inequality relationships between angles and sides in two triangles.

Objective

Apply inequalities in two triangles

Objectives derived from Pearson Education programs © Pearson Education, Inc., or its affiliates. All rights reserved.

Tip: You will have two days to complete this lesson.

----------------------------

Relationships in Triangles

Click on the link below to complete the Solve It! for Chapter 5, Lesson 7 from the PowerAlgebra website.

Solve It!

Click on the link below to watch the "Inequalities in Two Triangles” Teachlet® tutorial. As you view the tutorial, review the lesson objectives and be sure that you are comfortable with the concepts presented before continuing with the lesson..

Inequalities in Two Triangles

Read pp. 332–335 in Geometry. Take note of the Hinge Theorem on p. 332 and its converse on p. 334.

Tip: Recall that an included angle in a triangle is formed by two sides of a triangle and therefore is located between the two sides.

Click on the link below to access the online textbook.

Geometry

------------------------------

Complete the following activities.

Recall the robotic arm problem from the beginning of this lesson. The diagrams to the right show the triangles formed by robotic arms in two different positions. In which position is the end of the robotic arm closer to the base? Explain your reasoning.

Write the Hinge Theorem and its converse as a biconditional.

Click on the Show Answer button below to check your answers.

Answers:

The end of the robotic arm with the 40o angle is closer to the base. The lengths of the two sections of the robotic arm do not change as the arm moves, but the included angle changes. By the Hinge Theorem, the triangle with the larger included angle is opposite the longer side of the triangle.

Two sides of one triangle are congruent to two sides of another triangle, and the included angles are not congruent if and only if the longer third side is opposite the larger included angle.

or

Two sides of one triangle are congruent to two sides of another triangle, and the third sides are not congruent if and only if the larger included angle is opposite the longer third side.

Complete problems 7, 9, 11, 13, 15, 19, 21, and 23 starting on p. 336 in Geometry.

Click on the link below to complete the 5-7 Enrichment activity.

5-7 Enrichment

When you have finished, click on the link below to check your answers to the 5-7 Enrichment.

Answers

Click on the link below to access the online textbook.

Geometry

Extension: Click on the link below view the "Using Inequalities Involving Angles of Triangles" and "Using Inequalities Involving Sides of Triangles" Homework Video Tutors for Chapter 5, Lesson 6 from the PowerGeometry website.

Using Inequalities Involving Angles of Triangles

Using Inequalities Involving Sides of Triangles

---------------------------------

Complete the following review activities.

In this lesson, you learned about inequalities in two triangles using the Hinge Theorem and its converse. Be sure you understand how to use the Triangle Inequality Theorems and can apply the concepts to solve problems involving triangles that have two pairs of congruent sides. At the end of this lesson is a quiz covering the lessons listed below. The activities that follow will provide review practice of the concepts in order to prepare for the quiz.

Lesson 4 – Medians and Altitudes

Lesson 5 – Inequalities in One Triangle

Lesson 6 – Inequalities in Two Triangles

Complete the Lesson Check on p. 336 of Geometry.

Complete Got It? for problems 1–5 starting on p. 325 of Geometry.

Click on the link below to complete the Self-Assessment 5-4 activity from the PowerGeometry website.

Self-Assessment 5-4

Click on the link below to access the online textbook.

Geometry

----------------------------------------

Inequalities in Two Triangles

Kenneth Clark is taking this assessment.

Multiple Choice

1. In ABC, centroid D is on median . AD = x + 5 and DM = 2x – 1. Find AM.

(1 point)

11

5

12

2. Where can the lines containing the altitudes of an obtuse triangle intersect?

I. inside the triangle

II. on the triangle

III. outside the triangle (1 point)I only

I or II only

III only

I, II, or III

3. Where can the medians of a triangle intersect?

I. inside the triangle

II. on the triangle

III. outside the triangle (1 point)I only

III only

I or III only

I, II, or III

4. Which labeled angle has the greatest measure? The diagram is not to scale.

(1 point)

There is not enough information in the diagram.

5. Name the smallest angle of ABC. The diagram is not to scale.

(1 point)C

A

Two angles are the same size and smaller than the third.

B

6. Three security cameras were mounted at the corners of a triangular parking lot. Camera 1 was 151 ft from camera 2, which was 122 ft from camera 3. Cameras 1 and 3 were 139 ft apart. Which camera had to cover the greatest angle? (1 point)camera 1

camera 2

camera 3

There is not enough information to tell.

7. List the sides in order from shortest to longest. The diagram is not to scale.

(1 point)

8. Which three lengths CANNOT be the lengths of the sides of a triangle? (1 point)25 m, 16 m, 10 m

15 m, 13 m, 12 m

18 m, 5 m, 10 m

8 m, 8 m, 15 m

9. Which of the following must be true? The diagram is not to scale.

(1 point)BC < FH

AC = FH

AB < BC

AC < FH

10. If mDBC = 65°, what is the relationship between AD and CD?

(1 point)AD > CD

There is not enough information to tell.

AD < CD

AD = CD

Short Answer

Note: Remember to show all of the steps that you use to solve the problem. You can use the comments field to explain your work. Your teacher will review each step of your response to ensure you receive proper credit for your answer.

11. What is the orthocenter of the triangle with two altitudes given by the lines x = –1 and y = x + 1?

(2 points)

12. What is the range of possible values for x? The diagram is not to scale.

(2 points)

13. What are the missing reasons in the two-column proof?

Given:JM = ML and mJMK > mKML

Prove: JK > KL

Statements Reasons

1. JM = ML 1. Given

2. KM = KM 2. __?__

3. mJMK > mKML 3. Given

4. JK > KL 4. __?__

(2 points)

14. Two sides of a triangle have lengths 11 and 18. Write an inequality to represent the possible lengths for the third side, x. (2 points)

15. Find the length of , given that is a median of the triangle and AC = 50.

(2 points)

16. You have two pieces of wood that will make up two sides of a triangular picture frame. One is 6 in. long and the other is 7 in. long. What is the range of the possible lengths for the third side of the frame? (2 points)

17. Given ΔDEF with D(–4, –1), E(–1, 8), and F(5, 4), find the median DT in point-slope form. (2 points)

This post has been edited by **Curtis Rutland**: 08 December 2011 - 12:22 PM

Reason for edit:: added spoiler

Posted 08 December 2011 - 06:40 PM

The_Programmer-, on 08 December 2011 - 01:37 PM, said:

Lol. Okay. But do any of you know how to make it so you can import an image which is a grid filled with different colored squares and based on those colors you could print images on a JPanel in the same grid arrangment but instead of the colored squares you could have images?

You may want to take a look at BufferedImage for examining each individual pixel. Also, see the GridLayout, JLabel and ImageIcon classes. The JLabel class has a setIcon() method you can use to pass the ImageIcon. Really, for much more sophisticated Image analysis, the JAI API is what you want to use.

- Caffeine Lounge
- Corner Cubicle
- Student Campus
- Software Development
- Industry News
- Introduce Yourself
- Nightmare.In.Code

- C and C++
- VB.NET
- Java
- C#
- ASP.NET
- .NET Framework
- VB6
- PHP
- Ruby
- Python
- ColdFusion
- Databases
- Other Languages
- Game Development
- Mobile Development
- 52 Weeks Of Code

- Web Development
- HTML & CSS
- JavaScript
- Graphic Design
- Flash & ActionScript
- Blogging
- SEO & Advertising
- Web Servers & Hosting
- Site Check

- Book Review: Murach's Java Servlets and JSP
- Phobos - A JavaFX Games Engine: Part 2 - JavaFX Scene API and the FSM
- Maven Tutorial 2 - Adding Dependencies
- Maven Tutorial 1 - Installation and Getting Started
- Phobos - A JavaFX Games Engine: Part 1 - Intro to Threading and DP
- Swing to JavaFX
- Swing, Top-Down 2
- Swing, Top-Down (with GridBagLayout)
- Basic Java: Types, Variables, Operators
- Simple Regression Library Part 2 - Linear Regression Model
**216 More Java Tutorials...**

- C Snippets
- C++ Snippets
- Java Snippets
- Visual Basic Snippets
- C# Snippets
- VB.NET Snippets
- PHP Snippets
- Python Snippets
- Ruby Snippets
- ColdFusion Snippets
- SQL Snippets
- Assembly Snippets
- Functional Programming Snippets
- Perl Snippets
- HTML/CSS Snippets
- Javascript Snippets
- Flash/ActionScript Snippets
- Other Languages Snippets

Copyright 2001-2014 **MediaGroup1 LLC**, All Rights Reserved

A**MediaGroup1 LLC** Production - Version 6.0.2.1.36

Server: secure3

A

Server: secure3