BBC BASIC for Windows
« simple method for rotating graphics »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:10pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: simple method for rotating graphics  (Read 773 times)
gaui65
New Member
Image


member is offline

Avatar




PM


Posts: 0
xx simple method for rotating graphics
« Thread started on: Oct 14th, 2013, 9:58pm »

Lets say i drew a triangle and wanted to rotate it. It would be great if i could group all the lines forming the triangle and then use a ROTATE(group,x,y,step) where the x and y is the rotation point. This would be a great tool.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: simple method for rotating graphics
« Reply #1 on: Oct 14th, 2013, 11:05pm »

on Oct 14th, 2013, 9:58pm, gaui65 wrote:
Lets say i drew a triangle and wanted to rotate it. It would be great if i could group all the lines forming the triangle and then use a ROTATE(group,x,y,step) where the x and y is the rotation point. This would be a great tool.

It would be easy enough to do that in the specific case of a triangle. Just write a procedure which receives the X,Y coordinates of the three vertices, the X,Y coordinates of the axis of rotation, plus an angle. The procedure would then plot the triangle rotated about the specified point by the specified angle. It's just simple trigonometry.

You could extend that technique to a larger number of lines, e.g. a rectangle, by passing (for example) arrays containing pairs of X and Y coordinates defining the end-points of the lines.

Another approach might be to use the SetWorldTransform API to get Windows to do the rotation for you. It's rather tricky to use but with a bit of care could perhaps be made to do what you want.

Where it starts to get more difficult is when the rotated 'object' is made up of some filled (solid) areas as well as lines. At that point you may want to use a method which will rotate an arbitrary image; one such would be the Windows API function PlgBlt. Although it's not documented as being specifically suitable for performing rotations, in fact it does so reasonably well.

The program rotateimage.bbc, which you can find in the Graphics folder on the old Yahoo group, uses that technique and could perhaps be adapted.

I should also mention those GFXLIB modules which support rotation, such as plotrotatescalebilinear, which were used to good effect in the BOX2D demonstrations such as the falling crates demo.

Richard.
« Last Edit: Oct 15th, 2013, 03:09am by admin » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls