Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Formulas. (https://forums.graalonline.com/forums/showthread.php?t=23369)

joseyisleet 02-09-2002 01:11 AM

Formulas.
 
-=Josey=-
Someone asked for the formula on a circle a while back, so I decided to start a thread on other formulas with the area and perimeter of an object. Please add to this thread so we can have more moving objects. ;D

A = Area
B = Base
C = Circumference
D = Diameter
S = Side
L = Lenght
H = Height
P = Perimemter
R = Radius
Pi = 3.14
* = Multiplied by

-=Areas=-

Square:
A = S*2

Rectangle:
A = L*W

Parallelogram:
A = B*H

Triangle:
A = .5*B*H

Circle:
A = Pi*R*2

-=Perimemter=-

Square:
P = 4*S

Rectangle:
P = 2*L+2+W

Triangle:
P = S1+S2+S3

Circumference of a circle:
C = Pi*D


These are all of the basic ones. If you have any, post em! ;D

kyle0654 02-09-2002 01:42 AM

Please excuse me if some of these don't work. They should, but it's been a while since I've scripted.

New Variables in red.


Ang = Angle, in Degrees
Rad = Angle, in Radians


-= Degrees to Radians =-

Rad = Ang * Pi / 180
Ang = Rad * 180 / Pi

-= Location of a point on a circle =-

X = X of point on circle
Y = Y of point on circle

X = cos(Ang)*R
Y = sin(Ang)*R

-= Angle of a point on a circle (when angle is unknown) =-

OX = Origin X (center of circle)
OY = Origin Y (center of circle)

Rad = arctan( ( Y - OY ) / ( X - OX) ) + ( Pi * ( X < OX) )

joseyisleet 02-09-2002 01:54 AM

-=Josey=-
- Digs out some old mathemetics books and starts to look for some. People better use these or this thread is useless. ;\

Wes2000 02-09-2002 06:58 AM

Im pretty good at math, but sometimes i cant find a way to put the math into use in GScript. Could someone post a short example possibly moving a object with one of the formulas or anything real simple?

Lomgren 02-09-2002 09:45 AM

Polar Coordinates!!
 
[EDIT] the forum replaced my theta with a sideways E so don't yell at me[/EDIT]

*sits down with dusty old book in lap*
Heh, these are fun indeed!
:New Variables:
Ø - theta (inner angle of a circle, 360 deg. 1 radian)
a - any real number
b - any real number
n - any positive integer

:Formulas:
-Rose-
R = a*cos(n*Ø)
R = a*sin(n*Ø)

-Lemniscate-
R^2 = a^2*cos(2*Ø)
R^2 = a^2*sin(2*Ø)

-Limaçon-
R = a + b*cos(Ø)
R = a + b*sin(Ø)

-Cardioid-
R = a + a*cos(Ø)
R = a + a*si(Ø)

-Spiral of Archimedes-
R = a*Ø

-convert polar to rectangle coordinates-
x = R*cos(Ø)
y = R*sin(Ø)
-or for graal's y scale-
y = -R*sin(Ø)

and for a simple script to test these formulas;
[script]
for (i=startx;i<=lastx;i+=interval) {
<insert formula here, but use i for the non-constant variable
<(Ø for most formulas, change all others to your descretion>
showimg i*(1/interval),kstar.gif,x+g,y-h;
}
[/script]

but change the startx, lastx, and interval to what you want,
and replace the x with g, and y with h in the formulas,
except for the polar graphs, just use the conversion formulas.


:)

BocoC 02-09-2002 09:58 AM

Re: Re: Polar Coordinates!!
 
Quote:

Originally posted by Kaimetsu


:confused:

You're saying that 360 degrees = 1 radian?

If I'm not mistaken, 6.28318530717958647692528676655901 radians equals 360 degrees.

Lomgren 02-09-2002 09:59 AM

Re: Re: Polar Coordinates!!
 
Quote:

Originally posted by Kaimetsu


:confused:

You're saying that 360 degrees = 1 radian?

[Embarassment]
oops, I messed that up bad,hehe

2pi radians equals 360 degrees
[/Embarassment]

I tend to forget things, even if I just learned them six months ago!

dragoonvenganc 02-09-2002 12:33 PM

Kammy if im not mistaken.. in math
if u write
ab
that means the same as
a*b..
so 2pi=2*pi
because when u say 2 pi u mean u have 2 of pi. so that means u would multiply them.

G_yoshi 02-09-2002 01:06 PM

Quote:

Originally posted by dragoonvenganc
Kammy if im not mistaken.. in math
if u write
ab
that means the same as
a*b..
so 2pi=2*pi
because when u say 2 pi u mean u have 2 of pi. so that means u would multiply them.

correct :D

Faheria_LAT1 02-09-2002 01:12 PM

Quote:

Originally posted by dragoonvenganc
Kammy if im not mistaken.. in math
if u write
ab
that means the same as
a*b..
so 2pi=2*pi
because when u say 2 pi u mean u have 2 of pi. so that means u would multiply them.

yeah but if you would read the quote it shows pi, not 2pi

Wes2000 02-10-2002 02:28 AM

For constant acceleration
d = d0 + vt + .5at^2
v = v0 + at
v^2 = 2ad

Acceleration on a cylinder (space colony, etc.) of radius r and
rotation period t:

a = 4 pi**2 r / t^2

For circular Keplerian orbits where:
Vc = velocity of a circular orbit
Vesc = escape velocity
M = Total mass of orbiting and orbited bodies
G = Gravitational constant (defined below)
u = G * M (can be measured much more accurately than G or M)
K = -G * M / 2 / a
r = radius of orbit (measured from center of mass of system)
V = orbital velocity
P = orbital period
a = semimajor axis of orbit

Vc = sqrt(M * G / r)
Vesc = sqrt(2 * M * G / r) = sqrt(2) * Vc
V^2 = u/a
P = 2 pi/(Sqrt(u/a^3))
K = 1/2 V**2 - G * M / r (conservation of energy)



Anyone think they can use those?

KJL 02-10-2002 02:37 AM

Re: Formulas.
 
Quote:

Originally posted by joseyisleet
-=Josey=-
Someone asked for the formula on a circle a while back, so I decided to start a thread on other formulas with the area and perimeter of an object. Please add to this thread so we can have more moving objects. ;D

A = Area
B = Base
C = Circumference
D = Diameter
S = Side
L = Lenght
H = Height
P = Perimemter
R = Radius
Pi = 3.14
* = Multiplied by

-=Areas=-

Square:
A = S*2

Rectangle:
A = L*W

Parallelogram:
A = B*H

Triangle:
A = .5*B*H

Circle:
A = Pi*R*2

-=Perimemter=-

Square:
P = 4*S

Rectangle:
P = 2*L+2+W

Triangle:
P = S1+S2+S3

Circumference of a circle:
C = Pi*D


These are all of the basic ones. If you have any, post em! ;D

humm I beleve a square is

Square:
A = S^2 (not A=S*2)

and

Rectangle:
P = 2*L+2*W (not P = 2*L+2+W)

joseyisleet 02-10-2002 10:20 PM

-=Chicken is confusled rofl=-
 
[confuzed]Im is Confused lol i have a learning Disablility Dislexia,and like rofl this shi*s hard core maths rofl but please correct me if im wrong but That square thingy mabob wouldnt in include 4 in dah formula case of 4sides for faces and yah like maybe 2*4+16 or some crap lol [/confuzed]

joseyisleet 02-11-2002 06:12 AM

-=ohh um heh=-
 
Ohh,well i thought considering that theres like 4 sides 4 faces and Shiot that it would have something like that but ehh i was wrong and i was like 99.9 percent sure i was wrong rogl =D

LiquidIce00 02-11-2002 06:31 AM

line in intercept slope form
y=mx+b

slope
m=(y2-y1)/(x2-x1)

y intercept
b=-m*x+y;

Distance formula
d=((y2-y1)^2+(x2-x1)^2)^.5

taki 02-12-2002 08:26 PM

[off-topic]dimensional analysis>algebraic method

Actually, I dunno.. I'm comfortable with computing in algebraic expressions, but with dimensional analysis, things seem to fit together more and it gets convenient when keeping track of different variables, labels, and formulas[/off-topic]

Oh well, here's a bunch of formulas, some may be redone but for the sake of convenience I haven't bothered to edit them out:

Acceleration- s=vi tat²
The distance s an object travels can be computed when the initial speed vi , time elapsed t , and the rate of constant acceleration a is known.

Angular velocity- w=Ø/t'
Where Ø is expressed in radians and t represents time.

Geometry:
Parallelogram- A=bh
Rectangle= P=2(l+h) A=l*h
Right triangle A=ab/2 Pythagorean Theorem- c²=a²+b²
Isosceles Triangle- A=bh/2
Circle- P=2pi*r A=pi*r²
Trapezoid- A=h/2(b1 +b2 )

Artificial Gravity- N=1/2pi*sqrt a/r
Where N, the number of rotations required per second to maintain an acceleration of gravity of m/s².

Carrier Wave- y=A sin(10^7*2pi*t)
t is the time in seconds.

Change of Base- loga n=logb n/logb a
For all positive numbers a,b, and n where a and b do not equal 1.

Compound Interest- A=P(1+r)^t
A is the balance, P is the amount invested, r is the interest, and t is the time in years that the money was invested.

Distance Travel- d(t)=vi t+½at²
The distance d that an object travels can be calculated when the initial speed vi, elapsed time t, and the rate of constant acceleration a are known.

Falling object's duration in air- t=sqrt 2d/g
the time t equals d, the height at which the object is dropped and g is the acceleration due to gravity.


Growth and Decay- y=ne^kt
y is the final amount, n is the initial amount, k is a constant, and t is the time.

Height of Projectile- h=(vo ²sin²Ø/2g
Ø is the measure of the angle between the ground andthe initial path of the ball, v0 is its initial velocity in m/s, and g is the acceleration due to gravity.

nth term of an Arithmetic Sequence- an=a1+(n-1)d
The nth term of an arithmetic sequence with the first term a1 and common difference d.

nth term of a Geometric Sequence- an=a1*r^(n-1)
The nth term of a geometric sequence with the first term a1 and common ratio r.


Quadriatic Function- y=ax²+bx+c
Formula- -b±sqrt (b²-4ac)/2a

Snell's law- n=sin I/sin r
Where n is the index of refraction, the angle of incidence I and the angle of refraction r.

gah.. too tired.. must.. get.. sleep x_x zZzZ

Torankusu 02-13-2002 04:18 AM

B is for volume, b is for surface area/area.

taki 02-13-2002 06:56 AM

Quote:

Originally posted by Kaimetsu
It intrigues me that people are deciding it would be cool to just copy lots of irrelevent formulae from a textbook just to look intelligent.
actually, quite a few of these can be used, but not really as useful as geometric formulae.. the ones i put are mainly for the 'realism' of the npc in the terms of physics. the nth term of sequences might be used for figuring in advance distances and waypoints, based on the players movement (back to finding the recursive formula for that, lol). compound interest may be used for future banks scripts, growth and decay probably for npcs that deal with projection/reduction of a statistic, and logarithms mainly for convenience.. I did in fact scan textbooks for these formulae, but filtered out those with no obvious relevancy.

However, with everyone providing all these formulae, doesn't one have to 'translate' them for it to be actually be used in a graal-compatible script? :eek: :rolleyes: ;)

taki 02-13-2002 06:59 AM

wait..nevermind, lol
i just remembered most of these deal with variables, but they still have to be formatted correctly to work.


All times are GMT +2. The time now is 11:44 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.