I have tried and failed to find an Applescript code that returns a smart object's current rotation angle in Photoshop. Anyone have an idea of where that property is listed? I'm beginning to think this feature isn't currently supported by Applescript.
In Photoshop, objects like a selection has no angle value, because it means nothing: if your selection is made by multiple segments making a complexe shape, there is no mathematical way you can define angle for that shape !
However, you can work with boundary rectangle (which includes that shape). You can rotate this complete boundary (i.e. the selection) and then you will get a new boundary (new rectangle where new rotated shape fits in).
A boundary rectangle is made of a list of for values :
top left corner horizontal position (X1)
top left corner vertical position (Y1)
bottom right corner horizontal position (X2)
bottom right corner vertical position (Y2)
Positions are real numbers, starting with border of canvas (not border of layer ! so you may have negative values). The units depends of the unit of measure of the document.
Once that's clear (I hope !) if you use mathematical calculation between initial boundary and new boundary, you can calculate the rotation angle:
(Pythagore triangle)
If you assume that initial rectangle borders were vertical and horizontal :
cosinus (Teta) = (X2-X1) / (X'2 - X'1)
Teta = angle you are looking for
X1, X2 are the positions of the boundary corners before rotation and X'1, X'2 are position of same corners after rotation.
Please note that this method is OK for selection (any shape), or layers.
It should also be OK for the full canvas, but I never test it for canvas.
Related
How elements with rounded edges (border-radius) or rotation are calculated along the mouse point? Is it SAT? How corner angles are defined?
Mouse point/pixel represented as "cursor"
You can use the SDF of a 2D box minus the radius of the rounded corners and as said in the video, transform the space to make the translation and the rotation. To know if the cursor is in the box, you can just check if the result is negative or not.
There is a problem:
Have a rectangle, the coordinates of the lower left corner - (0, 0), upper right (width of the rectangle, the height of the rectangle). Inside this rectangle is the point having certain coordinates. I need to draw around this point a segment of a circle with a certain (const) arc length. Calculate the internal radius and the angle of the segment of a circle.
illustration:
Like this. As can be seen from the figure, if the segment to be placed in the side of the screen (eg bottom left), it is necessary to find such a range that it satisfies our long arc.
Prompt, in what side to search?
Thank you in advance.
I have a set of rectangle tiles, each of them with different shapes on them. One tile could for example contain the texture of a circle, another a rectangle, or maybe even a polygon.
These shapes do not fill up the whole tile, instead they are somewhere on the texture. One tile could for example just contain a small rectangle in the top-right corner. The other parts of the tiles are empty or transparent, i.e. these other pixels have an alpha value of 0.
Now I need to calcuate the "center of gravity" (CoG) within each tile. I know that is not be the best term to describe it, but I don't know of any better. With CoG in this context I mean the spot on the tile that is the center point of the shapes, i.e. those parts of the tiles that are not transparent.
For example, if the tile has one small rectangle in the top-right corner, then the CoG as I mean it would be in the center of the rectangle. In this case thus that CoG would not be in the center of the tile, but also somewhere in the top-right corner.
Important is that fact that the color of the shapes do not count. I am solely interested in the transparent vs. non-transparent pixels/areas on the tile.
Is there any "best practice" to calculate what I am looking for?
I'm developing an app that shows a mapview.
Superimposed at this I draw a rectangle that always has the center in the screen center, therefore the center of the map.
I can move a corner of the rectangle to resize it to select an area on the map.
I have only the coordinates (lat/lon) of the center of the rectangle (and of the map), the altitude and the size of the rectangle (pixel or cm).
How can I get the coordinates of the rectangle corners??
Should I calculate the scale between the size of the rectangle and the altitude of the map? and then?
please explain me this problem :)
thanks in advance
I found the solution.
I've developed the app for BlackBerry 10 and in MapView class there are some methods that are very useful.
Getting the coordinates of the corner of the rectangle drew on the mapview (for example to choose an area on the map)
using
bb::platform::geo::Point windowToWorld (const QPoint &windowCoordinates)
call windowToWorld passing the coordinates of the pixel of the corners, relatively to the axis origin. The method returns the coordinates (lat/lon) of the point on the screen (x,y).
WARNING: The origin of the window's coordinates are the upper left corner of the MapView window (not the screen), with positive values going right (x-axis) and down (y-axis).
If you want to do the inverse use the worldToWindow method that converts world coordinates (latitude/longitude) into window coordinates (pixels).
eg: draw a geo point on the mapview
i have a picture that captured from a fixed position [X Y Z] and angle [Pitch Yaw Roll] and a focal length of F (i think this information is called camera matrix)
i want to change the captured picture to a different position like it was taken in up position
the result image should be like:
in fact i have picture taken from this position:
and i want to change my picture in a way that it was taken in this position:
i hope that i could express my problem.
thnx in advance
It can be done accurately only for the (green) plane itself. The 3D objects standing onto the plane will be deformed after remapping, but the deformation may be acceptable if their height is small relative to the camera distance.
If the camera is never moving, all you need to do is identify on the perspective image four points that are the four vertices of a rectangle of known size (e.g. the soccer field itself), then compute the homography that maps those four points to that rectangle, and apply it to the whole image.
For details and code, see the OpenCV links at the bottom of that Wikipedia article.