Vector Math - Calculate Equation Of A Plane That Would Rely On All Axis

Jan 27, 2014

I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axis? Here is my current code:

Java Code:

Vector3f A = new Vector3f(0, 0, -1);
Vector3f B = new Vector3f(0, 1, -1);
Vector3f C = new Vector3f(1, 1, -1);

Vector3f v1 = new Vector3f(B.x - A.x, B.y - A.y, B.z - A.z);
Vector3f v2 = new Vector3f(C.x - A.x, C.y - A.y, C.z - A.z);

float[] i = new float[]{v1.x, v2.x};
float[] j = new float[]{v1.y, v2.y};
float[] k = new float[]{v1.z, v2.z};

[Code] ....

View Replies


ADVERTISEMENT

Math Equation Game - Making Answer As Question

Apr 26, 2014

I want make a math equation game. usually math game use equation for the question and we answer that equation. ex : what is the result of 2*5 / 2+2/ 2^2 etc. and we answering that. but i want to make it different so i want to make the equation answer as the question and the equation as the answer of the game. Ex : the question is 54 so we can answer it with 9*6 or 24+30. and this is my java code

package coba;
import java.util.Scanner;
public class Coba {

public static void main(String[] args) {
double angka = Math.random()*70;

[Code] ....

but when i run it the error code show like this : Quote

View Replies View Related

Simulate Airport - Calculate Average Time A Plane Stays Inside A Queue For

Nov 13, 2014

Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue.

Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue.

I have most of the code done as you can see below:

* Queue Interface: Queue.java
* Queue Implementation: ArrayQueue.java
* Demo Program: Airport.java

Right now, I am stuck on the first calculation which is trying to figure out the average size of the landing queue. For some reason, as you can see at the bottom of my demo program, the average always comes out to be 0.0 and I'm not sure what's wrong.

Secondly, how to calculate the average time a plane stays inside a queue for.

View Replies View Related

Create A Program To Calculate Roots For 2 Degree Equation

Oct 14, 2014

I just created a program to calculate the roots for a 2. degree equation, When I first created my program, I defined the r1 and r2 as double, but got an error saying they needed to be defined as String, why is that?When should I be using string? I am new to java and I have mostly only used int, double and Boolean so far.

import java.util.Scanner;
import java.text.DecimalFormat;
public class c3e1 {
public static void main(String[]args){

[code]....

View Replies View Related

Calculate Distance Between Two Coordinates And Determine How Much Of Which Axis To Increment / Decrement

Feb 1, 2015

Basically I'm looking for a way to make one object follow another. For example, if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this?

Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable. In other words I'm just trying to create a homing object.

View Replies View Related

Power Of Math - Calculate Volume Of A Cylinder By Asking User To Enter Height And Radius

Jan 29, 2015

How do you use power of math. I'm trying to write a calculator to calculate the volume of a cylinder by asking the user to enter the height and radius but when I use pow(2) it doesn't work. I imported java.lang.math class so i dont have to keep using math. for now my code runs just fine since I'm using radius * radius but I would really luv to use the power instead times each other when i have to use higher powers.

import java.util.Scanner;
import static java.lang.Math.*;
 public class Lab2 {
 public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
 
[Code] .....

View Replies View Related

Print Table (array) Where Have X Axis And Y Axis?

Apr 12, 2015

I want to print a table (array) where I have an X axis and a Y axis. 16x11. My code is as follows:

int Windchill [] [] = new int [16][11];
{
{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15} //X
{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50} //Y
};

The code doesn't work even though it's similar to

int Windchill [][] =
{
{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15}, //X
{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50}, //Y
};

if I remember correctly, the 2 are correct just written in different ways.

and I want it to print like this

{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15},
{ 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
10, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
20, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
25, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
30, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
35, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
40, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
45, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
50, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,}

where 0 is null (for now). I want to fill those in with a formula later, but I don't hardcoding them one by one is the most "efficient" way to do it

View Replies View Related

Coordinates Are Inside Of A Right Triangle On Imaginary Coordinate Plane

May 24, 2014

I'm having a random x and y coordinate generate and I need to check if the coordinates are inside of a right triangle on this imaginary coordinate plane.

View Replies View Related

Java - Compute PI Using Equation

Oct 24, 2014

Part 1: USING A WHILE OR A DO-WHILE LOOP write a program to compute PI using the following equation:

PI = 3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8) - 4/(8*9*10) + ...

Allow the user to specify the number of terms (5 terms are shown) to use in the computation. Each time around the loop only one extra term should be added to the estimate for PI.

Alter your solution from part one so that the user is allowed to specify the precision required between 1 and 8 digits (i.e. the number of digits which are correct; e.g. to 5 digits PI is 3.14159), rather than the number of terms. The condition on the loop should be altered so that it continues until the required precision is obtained. Note that you need only submit this second version of the program (assuming you have it working).

My output for part 1 is :

Enter number of wanted terms for value of PI
100
PI = 3.1666666666666665 Number of Term = 2
PI = 3.1333333333333333 Number of Term = 3
PI = 3.145238095238095 Number of Term = 4
PI = 3.1396825396825396 Number of Term = 5
PI = 3.1427128427128426 Number of Term = 6
PI = 3.1408813408813407 Number of Term = 7
PI = 3.142071817071817 Number of Term = 8
PI = 3.1412548236077646 Number of Term = 9
PI = 3.141839618929402 Number of Term = 10 ................ and so on

I know you have to compare value of current Pi to the previous one but I'm stuck.

View Replies View Related

Completing Mathematical Equation In JavaScript

Jan 29, 2015

This first part of code is my HTML

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<link href="jquery/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css"/>
<meta name="viewport" content="width=device-width, initial-scale=1">

[Code] .....

View Replies View Related

Difference From One Equation Is Being Added To Total Of Another

Jan 21, 2015

I am writing a program for finding the profit made after paying the broker. here is my code, I am wondering why Java

Code: paidBroker = commission + commissionAfterSale; mh_sh_highlight_all('java');

is being added to

Java Code: noProfit = profit - paidBroker; mh_sh_highlight_all('java');

Here is my full program, you can find these lines of code on lines 64 and 70.

Java Code:

import java.util.Scanner;
public class StockTransaction {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Variable Declaration Section

[Code] ....

View Replies View Related

Moving Object In Y Axis

Jul 10, 2014

I just have one problem with a "car" program in java. The objective is to move the car in the direction it is facing. Moving forward in the normal position (when the angle is zero) means moving in the x-axis. Choosing to turn the car function (for example: 90 ) and then using the forward function should move up or down the car in the y-axis. However the y-axis is not working.

Car2 Demo.rar
JPGMoveforwardfunction.jpg

View Replies View Related

Vector Pair In Java

Mar 29, 2015

I want to convert this following piece of c++ code into java...but i cannot find suitable substitute for vector pair...what shall i do?

#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
bool compare_polar (int x1, int y1, int x2, int y2) { // if p2 > p1 return true

[Code] .....

View Replies View Related

Looping Through Objects Vector

Nov 11, 2014

I'm having some issues, trying to solve this problem in java. I want to print some election results, and i have to loop through a vector of objects and retrieve the partial sums of each party's seats for each constituency and the national results for each party. For now i can print the results per contituency, but i'm having problems in getting the national results. Like, adding the seats for labour party in Constituency A and B and C, etc, and print the sum. And do the same for conservative party.

This is what i have.

Java Code:

while (i < h.geral.size()) {
show += "Constituency - "
+ ((Party) h.geral.elementAt(i)).getConstituency() + "

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Drawing A Semicircle Using Formula For The Equation Of A Circle

Sep 19, 2014

So Ive got to make a turtle on an image draw a semicircle that starts at the top of a circle and goes down and to the left, changing colors halfway through. I've got everything down, I can draw the turtles and make them do straight lines. My problem is more math related. I need to use the equation of a circle, give it points, and figure out how to write that code in java.

We use the equation for a circle: (x - a)^2 + (y - b)^2 = r^2

amanda.setName("amanda");
amanda.setShellColor(Color.BLUE);
amanda.setBodyColor(Color.RED);
amanda.setPenColor(Color.YELLOW);
amanda.setPenWidth(3);
amanda.forward();
amanda.turn(-90);
amanda.setPenColor(Color.BLUE);
amanda.forward(???);

the question marks are where I need to draw a line on an arc, like in the picture.

View Replies View Related

Java Objects And Classes - System Of Linear Equation

Mar 15, 2015

The question states: Design a class named LinearEquation

for a 2 x 2 system of linear equations:

ax + by = e

cx + dy = f

Where

x =

ed − bf/ad − bc

y =

af − ec/ad − bc

The class contains:

- Private data fields a, b, c, d, e, and f.
- A constructor with the arguments for a, b, c, d, e, and f.
- Six get methods for a, b, c, d, e, and f.
- A method named isSolvable() that returns true if ad−bc is not 0.
- Methods getX() and getY() that return the solution for the equation.

Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad − bc is 0, report that "The equation has no solution."

I believe that my program is correct because I am able to compile it and get no errors, however I have no clue how to display the information for x and y or display this equation has no solution if ad-bc=0.

Java Code:

import java.util.Scanner;
public class Exer911 {
public static void main(String[] args){
// Create a scanner system to hold the numbers for each variable
Scanner input = new Scanner(System.in);
// Prompt the user to enter a number for each of the variables

[Code] ....

How to get the information to display ....

View Replies View Related

Pong Game - Y Axis Collision Detection

Jan 28, 2014

I have made a "Pong" game and how to check if the ball has hit the top or the bottom of a paddle, however I do know how to check if it has hit the left or right side:

Java Code:

if((BALL.getX() >= LEFT_BAT.getX() && BALL.getX() <= LEFT_BAT.getX() + LEFT_BAT.getWidth()
&& BALL.getY() >= LEFT_BAT.getY() && BALL.getY() <= LEFT_BAT.getY() + LEFT_BAT.getHeight())
&& (BALL.getX() >= RIGHT_BAT.getX() && BALL.getX() <= RIGHT_BAT.getX() + RIGHT_BAT.getWidth()
&& BALL.getY() >= RIGHT_BAT.getY() && BALL.getY() <= RIGHT_BAT.getY() + RIGHT_BAT.getHeight())){
BALL.increaseDX();
BALL.setDX(-BALL.getDX());
} mh_sh_highlight_all('java');

It seems as though I would use the same code for checking the top or bottom.

View Replies View Related

JavaFX 2.0 :: Chart Axis Changing Color

Mar 20, 2015

I'm struggling to change the colour of the X and Y axis. I can change the colour of the ticks and the tick labels in CSS... But not the axis themselves.

View Replies View Related

JavaFX 2.0 :: Panel Effect - Rotation Along Its Y Axis

Dec 14, 2014

I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.

View Replies View Related

Swing/AWT/SWT :: Vector Is Used In ComboBox Model?

Sep 23, 2014

I understand how vectors work I'm currently using one to store my id's from my txt file but how do you put them in a defaultComboBoxModel?

DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel();
//declare a vector object that will hold a string (only thing that works with comboboxmodel
Vector<String> myVector=new Vector<String>();
//try statement
try{
FileReader fr = new FileReader(file);

[Code]...

Any example of how a vector is used with a defaultComboBoxModel so I can then use that to populate my JComboBox?

View Replies View Related

Accessing Vector Variables With Scanner?

Jan 26, 2015

When I input "the" or "and" I always receive "its not here" as the output. Why is this? I also tried printing the values of v.get(i).other and the system printed null twice.

public class Translator {
public String other;
public Translator(String x) {
x = other;

[Code].....

View Replies View Related

Converting From A Vector Containing Big Decimal To A Float

Mar 13, 2015

I'm having extreme difficulty in working with a Vector storing a column with a BigDecimal value, and converting that single value into a float. I'm not sure why the code was written this way, but basically, I'm working with something called a vector that has a single Big Decimal value/column (not sure what the correct terminology is), and I want to store that value in a float variable called "dp". However, I don't know how to convert from the Big Decimal to a float.

Code is below:

String s = "";
sql = "SELECT DiscountPercentRate FROM Attendees WHERE AttendeeId=" + attendeeId;
  Vector v2 = sqldb.getResults(sql); /*I know that sqldb.getResults(sql) returns a vector with a single BigDecimal column of 15.0, in the test example I'm using*/
if (!v2.isEmpty()) {
Vector data2 = (Vector)v2.elementAt(0);
if (!data2.isEmpty())

[Code] .....

In case you're wondering what the sqldb.getResults() method looks, like, here's a snippet of it - There's an else statement that triggers in my case, adding a BigDecimal column to a vector, and returns that vector.

Vector v = new Vector();
...
else {
BigDecimal bd = rs.getBigDecimal(i);
vCols.add(bd);
}
v.add(vCols);
...
return v;

How can I take the single result of my SQL query in that Vector/Big Decimal thing, and turn that result into a float value?

View Replies View Related

Difference Between ArrayList And Vector Class

Jun 26, 2014

What is the difference between ArrayList and Vector class

View Replies View Related

Writing / Reading To And From Vector In JAVA

Nov 20, 2014

I have a project where I am required to read and write a vector of bank account objects and I am struggling with this concept. I was able to figure it out when the accounts were not stored in a vector but now that I am dealing with vectorsThis is my best attempt. Even though I know it's wrong, what I am trying to do.write/read methods in main:

public static void readTrans()
{
textArea.setText("");
chooseFile(1);
try
{
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream in = new ObjectInputStream(fis);
for (int index=0; index != fileIndex; index++)

[code]....

View Replies View Related

How To Assign Numbers Obtain From Modular Equation To Certain Position In Array

Apr 16, 2015

My biggest issues are as follows:

1) I'm trying to use a logarithm to determine the length of a user input number. I keep getting an error stating <> indetifier expected. I'm assuming this means that the program is not recognizing the function of a logarithm. I know that normally you can include that information in the method, but my teacher has stated specifically that each of these methods be called something else, as shown in the code.

2) I'm not quite sure I understand how to assign the numbers I obtain from the modular equation to a certain position in the array. As I'm asking the user to input any number these values can change so therefore I can't simply state that first number = this place.Here is my code:

import javax.swing.*;
import javax.*;
public class getSize
{
public static void main( String[] args )

[code]...

View Replies View Related

Which Axis To Increment / Decrement With Inclusion Of Speed Variable

Jan 30, 2015

if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this? Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable.In other words I'm just trying to create a homing object.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved