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 Professional Discussion / 2D Vertice Rotation

Author
Message
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2013 20:23
Having some issues with my 2D polygon rotations:


Any help?

^ That's what she said.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Feb 2013 21:08
What's the problem exactly? Your code is a little hard to understand.

Is it not rotating around the correct point?

I don't see you subtracting the polygon's positions before rotating it, could that be the problem?

TheComet

http://blankflankstudios.tumblr.com/
"ZIP files are such a retarded format!" - Phaelax
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Feb 2013 21:55
I see a triangle rotating. What should I be seeing?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2013 23:00 Edited at: 12th Feb 2013 23:00
The shape outlined in cyan is what the white shape should look like.
The vertex coordinates are getting mangled somewhere.

Quote: "I don't see you subtracting the polygon's positions before rotating it, could that be the problem?"

I have that here:

I know I am using a lot of variables, I thought it would make it easier to read lol.

I am using Indigo now btw, you were right it is a nice IDE.

^ That's what she said.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Feb 2013 23:36
Is this the behaviour you're looking for?



For some reason it's rotated by 180°. The following seems to fix it, but perhaps you should dig deeper to see if there's some other problem before applying it:



Also, did you know that the Advanced2D plugin comes with a function called a2filltriangle?

Cheers,

TheComet

http://blankflankstudios.tumblr.com/
"ZIP files are such a retarded format!" - Phaelax
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2013 23:58 Edited at: 13th Feb 2013 00:09
Yay!



Thanks Comet.

I was just about to post a simpler exampler, maybe it is still interesting to people.

The points rotate together and in the right radii but are at the wrong angle-offset.

Now with your code they line up correctly:


Quote: "Also, did you know that the Advanced2D plugin comes with a function called a2filltriangle?"

No I didn't, I have never used any plugins!
There's a bunch of memblock-bitmap functionality I want to include in this "engine", like anti-aliasing and transparency (the triangles will be written into the memblock-bitmap instead of drawn directly), so I will have to see if Advanced 2D is compatible. I'm sure it is faster than my little DBC function.

^ That's what she said.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Feb 2013 04:00
I wrote several new drawing functions awhile back:
http://forum.thegamecreators.com/?m=forum_view&t=203590&b=6&p=0

I did have plans to convert them to drawing directly to a memblock instead, and a few I did in other smaller projects, but there was never a full library of them like this.

Some of them I adapted from your own code Obese.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Feb 2013 18:54
@Phaelax
Thanks, these should be useful. I'm honoured that you used my code.

^ That's what she said.

Login to post a reply

Server time is: 2026-07-07 05:15:36
Your offset time is: 2026-07-07 05:15:36