Using Matrix in BitmapData.draw() - actionscript-3

I need to draw a BitmapData into an other one and the result should be a tile formed by 4x the source at 1/4 the size.
Right now I am using 4 calls to BitmapData.draw() with a matrix to scale down the source and a clip rectangle to draw in each corner, but I'm wondering if the same result could be achieved with a single draw call.
Thanks
Thomas

Related

How do I estimate 3D position of an object in video?

I want to find a 3D position coordinates (X, Y, Z) of a moving object.
I have a training set of pictures (frames from video) with a known ground truth XYZ position of an object.
The goal is to detect the object in the the input video and draw overlay with bounding edges and XYZ coordinates in real time 30fps.
Video stream is captured from a single fixed camera. Camera axis are not aligned with a world coordinate system (it's tilted and rotated). There will be maximum one object in a frame.
Is there existing models that can do it? Where can i start from?

Static image positioned far north gets stretched

In our application we have a backend that does some raster processing on a region of a map and sends back an image to the OL-based frontend which inserts the image at the specified extent.
The polygon to process is sent as GeoJSON-coords (EPSG:4326) to the backend which then transforms the polygon to a rectangular projection (EPSG:3035 in this case), does the processing and sends the heatmapped results back to the frontend as a PNG-encoded image, reprojected server-side to EPSG:3857 (to match the projection of our OSM-based background map). The image is then inserted in an ImageLayer using an ImageStatic object, whose extent is computed by the backend (the EPSG:3035-transformed bounding box of the image transformed to EPSG:3857).
This works fine, except for polygons in the far north of Scandinavia. For instance, the image whose extent in EPSG:3857 is [1684632.9133543067,9544855.787615912,2902401.684702249,10831736.048522325] is visualized the following way when added to the map:
The desirable result is for the image to follow the south-eastern boundaries of the shadowed polygon. Instead it is skewed and stretched out to the north-east.
I would be very grateful for any ideas and pointers as to why this is not working as expected.
I solved this by cropping the image to be reprojected as much as possible. The resulting envelope is then much smaller which did away with the distortions. Thanks for hint #Ian!

Function for densest sphere packing inside a sphere

I'm trying to write a function for the densest packing of identical spheres inside a spherical boundary.
I'm thinking it will be something like spherepack(c,r,n), where:
c - centre of the boundary sphere (x,y,z coordinates)
r - radius of the boundary sphere
n - number of identical spheres to be packed inside the boundary
I want the outputs to be the x,y,z coordinates of the centre of each packed sphere. Does anyone know how this could be done?
How about what you might call the 'brute force' method. ie Model what would happen if you had a pile of n unit sized spheres and just tried packing them together in every possible close-packed configuration, and then measured the smallest containing sphere for the pack. I can imagine an algorythm for that, but it is not very programatically efficient, or mathmatically beautiful. Would it have to run fast, or just get the right answer?
Unfortunately, the assumption that close packing is densest is not correct :(

Away3d building an irregular Polygon as a plane

I have a sprite which helps the user draw a custom shape? i want to tile the surface how can that be achieved?
Use EarCutting for Triangulation.
Convert your 2D points to 3D points for(Away3D).
Use the points to build custom Mesh.
Bingo!!
> The tricky part is to calculate the UV for the texture

Libgdx tile map drawing wrong tiles

I'm trying to make a tile map in libgdx. I have made all the tile images and used TexturePacker2 to pack them. When I load the game, it is rendering the map but using the wrong tiles. It appears to be using column first indexing while Tiled Map Editor is using row first.
For example, my packed tile image is a 5x5 grid. I used the tile at the 3rd row, 5th column (saves as 15) in the editor and then libgdx has used the tile at the 5th row, 3rd column.
What am i doing wrong?
The indexes in the packfile we all wrong. I'm not sure why they were wrong but I manually corrected them so that the tile in the top left was index: 0 and to the right of that was 1 and so on up to 24 in the bottom right.
My map draws correctly now.