Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Math Question

Author
Message
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 2nd May 2003 04:21 Edited at: 2nd May 2003 04:24
I learned in Math the other day that you can draw a circle with this equation:

(X-H)^2+(Y-K)^2<R^2

(darn my post got deleted)

so I plugged it in DB like this:

(object position x(1)-(a point))^2-(object position y(1)-(a point))^2<R^2

but it didn't work...... can somone tell me how to cheack if something is within a cirle

ps: yes I do listen in Math class

As I walk through the vally of the shadow of death, I will fear no evil.
- Psalms 23:4
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 2nd May 2003 04:43
you talkin 2D or 3D? if 3D the using the mathematical distance formula to detect if something is in range is the same thing as checking if something is within a circular perimeter of the target!

dist = sqrt( (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2 )

for 2D it would kinda be the same thing withought the z part to represent the 3rd dimension.

everyday of life is a new chapter that has already been fortold but is up to the soul to capture.
AsriCE
22
Years of Service
User Offline
Joined: 10th Jan 2003
Location: Brunei
Posted: 2nd May 2003 05:11
You can try using trigonometry to make circles. The following snippet is using 2D, but you can modify it easily to for your own use.



Asri CE Crew

Anak Brunei!
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 2nd May 2003 06:34 Edited at: 2nd May 2003 08:30
oh boy... variables can only be assigned in ANY programming language by the form of [variable] = [expression] (unless you use something like inc [variable] or [variable]++).

To draw a circle, use AsriCE's method if you need to do it mathematically; otherwise use the DB function.


EDIT: Hmm think I read this wrong; were you just trying to do a test instead of assigning a variable? In that case, your problem is that you used a "-" sign between squared terms instead of a "+".

Login to post a reply

Server time is: 2025-05-18 08:19:56
Your offset time is: 2025-05-18 08:19:56