VIEŠIEJI FORUMAI/BENDRASIS FORUMAS

Temos pavadinimas: Coding help (Paprasta tema)

Autorius: justanius

Tema pradėta: 22:56:06 2011 01 22

Pranešimai: 10 Paskutinis pranešimas: 00:28:38 2011 01 31. Autorius justanius

justanius Paskelbta: 22:56:06 2011 01 22

Pranešimai: 37

Temos: 9

Valstybė: United States

Lytis: Vyras



I'm having a major brain fart right now. I haven't done much coding in the last year (and I'm also not much of a mathematician). I'm trying to write a script that will calculate the distance between an object and a destination

This is written in PHP by the way.


$xd = ($object['x]) - ($destination['x']);
$yd = ($object['y]) - ($destination['y']);
$zd = ($object['z]) - ($destination['z']);

//Sqrt is a square root function, and pow($xd, 2) is $xd squared.

$distance = Sqrt((pow($xd, 2))+(pow($yd, 2))+(pow($zd, 2)));

Not sure what I'm doing wrong. I honestly don't think anything is wrong with my math. I'm getting a different number than what shows up on the I-flight page.




__________________________
AKA DRD, ED... and some other names I can't think of at the moment

Marvel Magnum Paskelbta: 23:54:08 2011 01 22

Pranešimai: 330

Temos: 27

Valstybė: Canada

Lytis: Vyras



I don't know PHP but the math looks ok. (Maybe if it was C++, I could have helped ... )




__________________________
"Marvel is my name, Marvellous is thy game."

Moiare Paskelbta: 10:55:33 2011 01 23

Pranešimai: 135

Temos: 6

Valstybė: United States

Lytis: Vyras



My PHP is rusty too, but are you missing some single quotes in the $object[ ] ?

$xd = ($object['x']) - ($destination['x']);
$yd = ($object['y']) - ($destination['y']);
$zd = ($object['z']) - ($destination['z']);




__________________________
Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life.

If you build it, they will complain.

justanius Paskelbta: 07:22:45 2011 01 24

Pranešimai: 37

Temos: 9

Valstybė: United States

Lytis: Vyras



Oh no, I'm not I just changed them to make them more easily readable.

I think either I'm missing something or SL's math isn't correct. dunno.




__________________________
AKA DRD, ED... and some other names I can't think of at the moment

Exemplary Strategy Paskelbta: 00:14:16 2011 01 25

Pranešimai: 928

Temos: 47

Valstybė: United States

Lytis: Vyras



what is the point, all you do is, +number to -number, in each area, and add the numbers.. so
13000:-5000:15600
-2456:-4590:-31005
13000+2456 + 1 is the space in first section
because the middle are both - instead of one of each, it's 410 higher number away from lower number,
third section, add the numbers 15600 and 31005 and 1.
add those, three distances, and you have the total. just make a calculator exactly that way, and you cant mess the math up.




__________________________
We have wings on our backs and we have horns on our heads, our fangs are sharp and our eyes are red, we're not quite demons or the one that fell, so choose to join us or go straight to hell!

Loyal as any dog.

Exemplary Strategy Paskelbta: 00:17:40 2011 01 25

Pranešimai: 928

Temos: 47

Valstybė: United States

Lytis: Vyras



im trying to do the if for the calculation, but i know NO php, so dont be mad if you have to help me, btw, will people hit me up on msn frotobagginses@hotmail.com, if you think you can help. i'll show you what i have so far.




__________________________
We have wings on our backs and we have horns on our heads, our fangs are sharp and our eyes are red, we're not quite demons or the one that fell, so choose to join us or go straight to hell!

Loyal as any dog.

Exemplary Strategy Paskelbta: 00:38:08 2011 01 25

Pranešimai: 928

Temos: 47

Valstybė: United States

Lytis: Vyras



<form method="get" action="action.php">

Enter the first coordinate First section <input type="text" name="number1">
Enter the first coordinate Second Section <input type="text" name="number2">
Enter the first coordinate Third section <input type="text" name="number3">
Enter the second coordinate First section <input type="text" name="number4">
Enter the second coordinate Second Section <input type="text" name="number5">
Enter the second coordinate Third section <input type="text" name="number6">
Parsec Calculator <input type="radio" name="op" value="dis">
submit <input type="submit" name="Submit" value="Submit">

<?php

if ( $op == "dis" ) {
echo "$number1 + $number4 = ";
echo $number1 + $number4;
echo "$number2 + $number5 = ";
echo $number2 + $number5;
echo "$number3 + $number6 = ";
echo $number3 + $number6;
}

?>




__________________________
We have wings on our backs and we have horns on our heads, our fangs are sharp and our eyes are red, we're not quite demons or the one that fell, so choose to join us or go straight to hell!

Loyal as any dog.

Exemplary Strategy Paskelbta: 00:39:46 2011 01 25

Pranešimai: 928

Temos: 47

Valstybė: United States

Lytis: Vyras



im sure you can tell i dont know php from this, but if it helps, use it.




__________________________
We have wings on our backs and we have horns on our heads, our fangs are sharp and our eyes are red, we're not quite demons or the one that fell, so choose to join us or go straight to hell!

Loyal as any dog.

Exemplary Strategy Paskelbta: 00:54:57 2011 01 25

Pranešimai: 928

Temos: 47

Valstybė: United States

Lytis: Vyras



the if statement i need help with, is a negative value checker, the problem is, i dont know how to do the math, i can do it without a calculator, making one for me is pointless, but, if someone wants it, that's a Great reason to make it.
so i was trying to figure it out, i googled it, and found something to test negative. i dont know how to edit it to fit this code i submitted a few minutes ago.


function change()
{
var temp = document.calculator.text.value;

if (temp.substring(0,1) == "-" )
{document.calculator.list.value = "";
document.calculator.text.value = 0 - document.calculator.text.value * 1}

if (temp.substring(0,1) != "-" )
{document.calculator.list.value ="";
document.calculator.text.value = "-" + temp.substring(0,temp.length)}
}
this statement, despite it not fitting file names, functions as such, if the number is negative, it changes it to positive.. which is what i want in negative numbers in the calculator, because it makes it simpler to calculate the distance total. say -1000 and 1000 are the distances, logic says, it's 2000 spaces, (gave up on counting 0) the calculator, would = them out to 0, because it's not using logic, it's using general math.
now, if both numbers are 5000 and 5064 for example, it would need an entirely different function, because adding those up would obviously = 10064 instead of 64.
someone teach me how to do this, it's gonna bug me forever :(




__________________________
We have wings on our backs and we have horns on our heads, our fangs are sharp and our eyes are red, we're not quite demons or the one that fell, so choose to join us or go straight to hell!

Loyal as any dog.

H911Reiver Paskelbta: 02:02:31 2011 01 27

Pranešimai: 1939

Temos: 44

Valstybė: United States

Lytis: Vyras



err, 1000 - (-1000) = 2000

you shouldn't have any mathematical issues like that, logic says it's 2000 spaces and math agrees




__________________________
Now with 93% less edge and teenage angst

justanius Paskelbta: 00:28:38 2011 01 31

Pranešimai: 37

Temos: 9

Valstybė: United States

Lytis: Vyras



Yea, but that would just be making it too easy on myself. haha




__________________________
AKA DRD, ED... and some other names I can't think of at the moment

Ankstesnis 1  Sekantis

© SkyLords 2002-2024 | SkyLords™ prekybos ženklas | Naudojimosi sąlygos | Privatumas | Susisiekti su mumis | Žaidimo DUK
VIEŠIEJI FORUMAI
TICKETS
KALBŲ FORUMAI
SKYLORDS POKALBIAI