Reply
finding square route with javascript???
Old 09-15-2005, 06:15 PM finding square route with javascript???
hiptobesquare's Avatar
Extreme Talker

Posts: 165
Location: London UK
Hi.
i have an interesting project writing a script that can calculate the angles and lengths required when cutting frame for use on sliding wardrobe doors with angled top corners (to accomodate sloping ceilings). My question: I know that to work out the hypotenuse of a triangle i add both sides together squared- then find the square root of the resulting figure. My problem is finding the square root of a number using javascript. Has anyone ever seen such a function???
hiptobesquare is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-15-2005, 06:17 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Code:
Math.sqrt(number)
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 09-15-2005, 07:00 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 165
Location: London UK
Oh i didnt know that. i just figured this out though
[javascript]
var z = 100;

$i=0;
while (i * i != z ){
i++;
}
[/javascript]
it will only work if var z has a whole number for square route but all the numbers i wouldv been working with did have.

I think il use your way anyway Oberon it looks to others like i know more JS then.
Thanks for helping out on another of my simple problems
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 09-15-2005, 07:08 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 165
Location: London UK
1000 posts. congratulations
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 09-15-2005, 08:13 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Yeah I know I made a celebratory post in the general forum...

I know next to no javascript, I just googled for 'javascript square root' and this came up. If you can raise numbers to powers you can get a square root by 'raising' something to the power of 0.5 also.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 02-21-2007, 08:26 AM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
How do u do power of a number in javascript
I am trying to do a script to calculate runway requirements and second of acceleration on a aircraft

like this
distance=1/2 * 8 (ft/sec) * t(secs)

How would u do that in javascript
Can some one HELP ME PLEASE
Thanks People

Quote:
Originally Posted by 0beron View Post
Yeah I know I made a celebratory post in the general forum...

I know next to no javascript, I just googled for 'javascript square root' and this came up. If you can raise numbers to powers you can get a square root by 'raising' something to the power of 0.5 also.
delta is offline
Reply With Quote
View Public Profile
 
Old 02-21-2007, 10:02 AM Re: finding square route with javascript???
willcode4beer's Avatar
Webmaster Talker

Posts: 696
Name: Paul Davis
Location: San Francisco
Quote:
Originally Posted by delta View Post
How do u do power of a number in javascript
I am trying to do a script to calculate runway requirements and second of acceleration on a aircraft

like this
distance=1/2 * 8 (ft/sec) * t(secs)

How would u do that in javascript
Can some one HELP ME PLEASE
Thanks People
Math.pow(number,power);

see:
http://www.w3schools.com/jsref/jsref_obj_math.asp
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 02-21-2007, 12:05 PM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
This is my code and it is blank in IE6 and firefox !
Where am I going wrong here ?

<html><head><title>Math and javascript</title></head>
<Body>
<table><tr><td>
<script language=javascript>
for (x=0;x<45;x++)
document.write "table 1"
document.write x
</script>
</td>
<td>
<script language=javascript>
document.write "table 2"
document.write (.5*8*Math.pow(x,2)+"<br>")
</script>
</td></tr></table>
</body></html>
delta is offline
Reply With Quote
View Public Profile
 
Old 02-22-2007, 03:20 PM Re: finding square route with javascript???
willcode4beer's Avatar
Webmaster Talker

Posts: 696
Name: Paul Davis
Location: San Francisco
Quote:
Originally Posted by delta View Post
Where am I going wrong here ?
What is the objective?
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 02-23-2007, 06:14 PM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
Quote:
Originally Posted by willcode4beer View Post
What is the objective?
Thanks I was able to work it out willcode4beer !
The objective was to calculate (distance = 1/2* g * t ^2 )
Thanks willcode4beer
PS: This is a great site !
delta is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to finding square route with javascript???
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15390 seconds with 12 queries