[SOLVED] Formula for position of opposite corners to default origin point corner

OK so
Looking at image below i have 2 corners
Red is origin point corner at x0 y0
Now to get position of yellow corner most simple formula is
Object.BoundingBoxLeft()+Object.Width()

But what if i do this?

I only changed angle of that object
To calculate position of yellow corner i would still need use this formula
Object.BoundingBoxLeft()+Object.Width()

But i would need to shove in somewhere Object.Angle()
And i do not know how to make proper formula for that

I start to doubt that i am even right about angle
Cause as it rotates not only Y position of yellow corner changes but also its X position

And nope adding points to the corner is not an option for me

Now that i think about it i would need something like
XFromAngleAndDistance()
YFromAngleandDistance()

1 Like

X, Y is the upper left corner and width. Is the width of the object. As long as it rotates around x, y.

X+XFromAngleAndDistance(Angle, Width) 
Y+YFromAngleAndDistance(Angle, Width) 

Edit : if it rotates from the center try this.

Purple is a tiled sprite. It gets the angle and distance from the center to the top left corner and puts it in angle and distance . It gets the x, y from the center and then uses x, y to calculate x1 and y1. Drawing a circle in both positions.

I tested it with a slider. Oh, distance1 is the width. Im assuming the width changes as it rotates.

Edit 2: you could probably get the angle and dist to both corners like for the first instead if the 2nd from the first. . It might even be a mirrored angle. IDK. I’m assuming the distance is the same to each corner.

Last edit. Calculating the distance once and the angle between the other 2 corners would be simplier.

How did you check it by drawing a circle?

And i think i failed at my concept from the start
I need to for minimap
And if i rotate that object then whole left GREEN side will be BoundingBoxLeft

While green circle will be corner from which it will start
And i need red circle position to properly calculate it
And i can’t find any means to determine that corner

BTW as for your idea THX it gave me better idea what to do from now on

1 Like

Yeah, I was drawing a circle with a shape painter with the last 2 actions.

1 Like

If you wanna try it out Data package from December 31st. - FileTransfer.io
Go to minimap tab
And to platforms group
Last NOT DISABLED is currently working

I gonna keep looking for a way to do it
This is just for you to play around if you want
Cause i remember you once told me you like challenges

Here’s my solution, the white dot is placed on the top right corner of the green box:

rotatePoint

I need it for minimap (i gonna make template out of it then try to turn it into extension)
I can’t expect any1 to create new object for each layer (layers in minimap display various stuff like on one layer you put all platforms on other enemies on another your player and so go on)
And i can’t use Object.PointX(“blablabla”)
Since it only works in change position action
And when i try to use it as expression either in text object or as coordinates for draw something with shape painter
It gives me error that it can’t find expression PointX
image

Points are only in sprites. Most if not all platforms are tile or panel.

I asked a chat bot and I got a formula on the 1st try.

This draws each point as a different size

image

If the rectangle is already rotated by an angle θ:

Let's define:
- (x, y) as the center point of the rotated rectangle
- w and h are the width and height (they stay the same after rotation) 
- θ is the rotation angle in radians

The corner points will be:

bottom-left: x - (w/2)*cos(angleRads) - (h/2)*sin(angleRads), y - (w/2)*sin(angleRads) + (h/2)*cos(angleRads)
bottom-left: x + (w/2)*cos(angleRads) - (h/2)*sin(angleRads), y + (w/2)*sin(angleRads) + (h/2)*cos(angleRads)
top-left: x - (w/2)*cos(angleRads) + (h/2)*sin(angleRads), y - (w/2)*sin(angleRads) - (h/2)*cos(angleRads) 
top-right: x + (w/2)*cos(angleRads) + (h/2)*sin(angleRads), y + (w/2)*sin(angleRads) - (h/2)*cos(angleRads)

Where:
- x, y is center point
- w, h are width and height
- angleRads is the rotation angle in radians

It can probably be simplified by make w and h as the values of w/2 and h/2

1 Like

I have no time today to test it since new year and crap but from what i understand from formula it should do exactly what i am asking for

Will test it in few days THX

Happy new year to all of you

1 Like

Happy New Year.:partying_face::balloon::balloon::balloon::balloon::balloon::balloon::balloon::balloon::balloon::balloon::balloon::balloon:

Would the Sprite Snapshot extension be of any use to what you are doing? Could you use that to take a snapshot of the scene (or part of it), put it onto a sprite, scale that sprite down and display it as a mini map?

1 Like

Depends
My method uses object masking to mask what is beyond white border of map BTW in my 3rd post here you have link to that minimap template
And it have comments on each part explaining what they are for and what they do even how to adapt it to your game
So you can check it out yourself

But that begs the question
How much of dynamic (Real Time) it would be?
Cause right now i am able to track position of anything in real time
Enemies or player even weapons thrown/bullets
Basically every single object
I can adjust colors/opacity of anything and/or give them outline even draw it as circles in their center instead of drawing their shapes as rectangles
And set how much distance from ANY point of what you see anything should be drawn
For example like only draw objects that are 100 pixels away from player
So it does not draw any single object in your scene
So that gives a lot of control
I did not check how much performance heavy it is
But how much performance heavy would be constantly taking snapshot of something and printing it in real time?
Also imagine you would wish to take snapshot of only platforms but not of enemies
Would that be possible without breaking them into different layers in editor?

Next thing
As i understand that sprite snapshot extension you mention would make kinda like screenshot or am i wrong?
But if i am right then would you wish have small image of what you see normally as your minimap?
Cause i think for a reason minimaps are made of simple solid objects
Instead of miniature of what you actually see
But that is also debatable from game to game
I gonna look into sprite snapshot and tell you of what use it can be

Seems smooth as for performance
But result does not

Layer to sprite

Rendering object to sprite
In this case it is object group in which are platforms

Rendering area to sprite
Seems buggy

And not to mention that pixelation effect
How much big of a minimap i would need to have for it to be usable
Where my minimap can go from very smal event to original size of what you have on screen

Sprite snapshot would be good for save slots icons or something like that
Like you make farming game and you have saves
And now you take snapshot and put next to save slot
Or to display small part of map
But not as minimap
I mean it could be used for it and adjusted to anyone needs
But i think effect would vary on what ppl expect from minimap

Another problem i just noticed
Probably can be solved somehow but i could not figure it out
Look this is me taking snapshot 4 times

It just pasted over 4 times same exact crap as you see there are 4 skeletons on the bottom which are copies of that ones skeleton above them
IDK how to clear snapshot after taking one so they do not overlap

You did in fact answer my question how to find corners THX
But i think now my problems comes more from with what action i try to draw it
Rather than what values i can provide
Look
image

It only wants position of sides
Not corners
Unless there is some way to shove there coordinates for both X and Y position at once
For example in 1st field it asks for Left X Position
Well i can give that
But for your method to work i would also need to be able to shove in there Y of that top left corner

I mean action is expecting position of walls so to speak
And i would need to provide position of exact points

The rectangle action is only going to draw unrotated rectangles.
If you want rotated ones then you could build a rectangle with lines.

I didn’t even need to retype anything. Change the first to a begin…, change the others to add to a path and add close the path. I had to move the last line up a spot so the points are added in the correct order.

THX Keith but that is not an option
Since it will be empty inside
So minimap would look kinda strange
I only wanted it so it accounts for platforms but are rotated
But i guess not many ppl will need it

What’s going to be empty inside?

Imagine minimap where every surface is rectangle made of outline

I could make background of whole map solid
But it would still look strange

The events I posted are for filled shapes. You can change all of the settings, colors and opacity.

1 Like

I forgot that it exist

Anyway

Why it is spinning so fast?