Graal Forums

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

Dach 08-18-2003 07:01 AM

Vector Trigonometry...
 
1 Attachment(s)
This is what I came up with for making a circle without sine or cosine. To me the script looks like its a bit too long for what needs to be done (not talking about relative to using sin and cosine), so I'd appreciate if someone could point out a simpler way to do this. Either way, I'll be able to use this in future scripts to alleviate cpu usage so I'm rather happy. Umm... *runs back to AS*

TribulationStaff 08-18-2003 07:24 AM

Works nicely. However, with such abbreviated variables, some comments would be nice. I can only make guesses at your thought process as is.

Tomorrow I will see what I can do.

adam 08-18-2003 07:28 AM

*digs out his old trig book*

Hmm.. Yes yes.. Now to try to understand what you just did there.

Dach 08-18-2003 10:40 PM

oops, forgot how hard it is to understand any script without any kind of help;
r - radius
px - pointx
py - pointy
seg - segment length (parts of a tile or something...)
^ edit those to change the effects
dx - x dist from center to point
dy - y dist from center to point
c - vector length from center to point
uc - altered vector length (makes seg usefull)
pdx - dist I want to move point x
pdy - dist I want to move point y
pndx - new dist for point y
pndy - ^ same for x
nc - new radius
unc - altered new radius (keep the radius the same)
pnx - new point x
pny - new point y

basically i'm finding the tangent to the current vector, then changing the vector without altering the radius

Python523 08-18-2003 10:50 PM

kai posted something that didn't require sin/cos besides for like 2 vars he created using it...I think I have it somewhere...

NPC Code:

if(playerenters){
this.rad=2.5;
this.x=0;
this.y=this.rad;
this.anginc=16/360;
this.s=sin(this.anginc);
this.c=cos(this.anginc);
timeout=0.05;
}
if(timeout){
this.x2=this.x*this.c-this.y*this.s;
this.y2=this.y*this.c+this.x*this.s;
this.x=this.x2;
this.y=this.y2;
x = 30 + this.x;
y = 30 + this.y;
timeout=0.05;
}


I might've edited it myself a little bit but oh well

Dach 08-19-2003 01:17 AM

Quote:

Originally posted by Python523
whatnot

Oh jeez, I've been looking for that on and off since this spring! Never asked anyone for it though...

wonderboysp2p 08-20-2003 06:35 AM

ask and you shall recieve :p


All times are GMT +2. The time now is 02:00 PM.

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