Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2006, 06:42 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Mathy stretchy stuff

Yeah, math (the stuff I need, anyway) isn't my strong point.

I have a 64x128 (4x8) image.
I want to rotate and stretch the image so it begins and point a and ends at point b.
I've played around with lots of tan, cos, and sin.. But I'm not getting anywhere.

Could someone help me out here? I had thought it would be easy, I'd just stretch the x to be equal to the distance and rotate it, but it turns out that stretchx and stretchy are applied after rotations.
Reply With Quote
  #2  
Old 08-30-2006, 06:03 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Quote:
Originally Posted by Yen
Yeah, math (the stuff I need, anyway) isn't my strong point.

I have a 64x128 (4x8) image.
I want to rotate and stretch the image so it begins and point a and ends at point b.
I've played around with lots of tan, cos, and sin.. But I'm not getting anywhere.

Could someone help me out here? I had thought it would be easy, I'd just stretch the x to be equal to the distance and rotate it, but it turns out that stretchx and stretchy are applied after rotations.
I could do anything with maths, it's just that I don't get what you want!
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #3  
Old 08-30-2006, 08:29 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Quote:
Originally Posted by contiga
I could do anything with maths, it's just that I don't get what you want!
These were my thoughts exactly.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #4  
Old 08-30-2006, 09:23 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Tolnaftate2004: That's what I was trying at first, but it didn't work.. :/

Okay.
Let's say I have a rope image, which is 4x8 tiles.
I want to show the rope so it stretches to fit from point a to point b.
Attached Thumbnails
Click image for larger version

Name:	stretchexample.PNG
Views:	134
Size:	2.7 KB
ID:	37626  
Reply With Quote
  #5  
Old 08-30-2006, 06:43 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
stretchx = imgx-pointa+(findimgwidth+pointb);

i dunno if that would work. :/
__________________
Deep into the Darkness peering...
Reply With Quote
  #6  
Old 08-30-2006, 07:50 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
This is theory, may not work. Pardon my bad drawing.



1. Let's say you have you image and points set up like this (this method should work for any set-up). First, find the distance between A and B.

2. Get the slope of AB by using deltay/deltax. You can get the angle to rotate by using arctan( slope AB ) or getangle( deltax , deltay ). The slope of CD is -deltax/deltay or -1 / tan( angle ). (The dashed corner is not at A, I just suck at drawing on the computer.)

3. The green axis helps us draw an angle, theta. Theta = arctan( slope of CD ). We can then reposition the image's top point at A by:
making x = A.x - cos( theta ) * ||CD||â€*
making y = A.y

â€* Note: ||v|| is vector notation for magnitude. I'm using it as distance. ||CD|| is the image's height.

4. Finish up by stretching the image.
stretchx = ||AB|| * cos( rotationangle )
stretchy = ||AB|| * sin( rotationangle ) ‡

‡ Note: it may be -sin() because of Graal's upside-down axes, but I'm not positive...

Voila!
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #7  
Old 08-31-2006, 05:49 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Ah I understand now. If stretchx and stretchy are applied after the rotation though, then applying either of them will make the rope 'thicker' (give it more width along its direction) as well as making it longer. That would make the rope look... odd.

Instead, if I remember correctly, recent GS2 changes allow for textured polygons, which would allow you to do what you want pretty easily.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #8  
Old 08-31-2006, 06:40 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Quote:
Originally Posted by Polo
Instead, if I remember correctly, recent GS2 changes allow for textured polygons, which would allow you to do what you want pretty easily.
I believe it was like;
PHP Code:
withfindImg200)) {
  
polygon = { x1y1x2y2x3y3x4y4};
  
image "lol.png";
  
dimension 2;

Not sure tho, look in Stefan's new features post, when V4.1 was released.
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:38 AM.


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