Matter.js: how to draw an ellipse? - matter.js

I am new to Matter.js. It is powerful, but surprisingly I found that it does not have a native method to draw an ellipse.
If I want to draw an ellipse, what can I do? Thanks

Related

How to draw a round map projection in R with a rectangle around specific area?

I need to make a map similar to this one in R, but drawing a rectangle in Uruguay:
I'm trying with ggplot, but the globe has no border, and I can't find the way to indicate the coordinates to draw the rectangle that interests me. This is what I have obtained following this web :
Any help is appreciated! Thanks
Here is a simple plot without ggplot. It uses the fact that in the maps package, the orthographic projection has co-ordinates on a circle of radius 1.
library(maps)
library(plotrix)
map("world", proj="orthographic", orientation=c(-20,-60,0))
draw.circle(0,0,1)
rect(.01,-.27,.11,-.17, border="red")
If you colour the map (fill=TRUE, col="grey"), you may see that Antarctica and possibly North America get some strange errors. That's because a part of the polygon is missing in this projection, and the simple "fill" algorithms can't really deal with that.
Your own plot also has such a straight line between two extremal points on Antarctica.

Draw circle with an EllipsePolygon in ImageSharp

I've just started using ImageSharp to draw images. The documentation on Six Labors web page is clean, but there is no examples to find anywhere about ImageSharp. So I struggle from time to time, all by myself :)
I want to draw a circle with PathBuilder and a given position in x and y as a center point, and a given radius.
I tried to use an EllipsePolygon where you can define x, y, and radius. And then I wanted to draw it in my PathBuilder but PathBuilder only has "AddEllipticalArc" what I can find.
So I have used this function to draw circles instead, like this for example:
pb.AddEllipticalArc(new Point(300, 200), 10, 10, 0, 0, 360);
Is there a better way to draw circles? Or am I supposed to use AddEllipticalArc?
Bonus question: I also have to draw Arcs with only a centerPoint, startPoint and endPoint given to me. But I guess I have to translate these given points and calculate the startAngle and sweepAngle myself. What could be the easiest alternative for this?

I am trying to make a half circle in sketchup

I'm trying to create essentially a half pipe shape in sketchup but having trouble. I can get an arc and build the shape, but it won't extrude.
Thanks,
Dirk
create a vertical rectangle then create your half circle on it.
Or using the tape measure, make sure all geometry is coplanar.
GIF explanation

Mapping points in 2d space to a sphere

I have a bunch of points in a rectangular x/y space which I would like to project onto a sphere. As in, I am trying to write this function:
function point_on_sphere(2dx:Number, 2dy:Number) : Vector3D
{
//magic
return new Vector3D(3dx, 3dy, 3dz);
}
I have been trying to first plot the points on to a cylinder and then map those points to a sphere as directed by this wikipedia page. However, those formulas assume a constant z=0, which doesn't really do what I want.
I'm using actionscript 3 / flex, but any pseudo code or pushes in the right direction would be greatly appreciated.
Just to clarify: I'm not trying to apply a texture to a sphere object, but rather to place objects along an imaginary sphere.
There is no one right answer. You can choose different approaches based on how you want to place the objects along the sphere.
Is it OK for the objects to get nearer and nearer to each other as you get closer to the sphere's "poles"? Why wouldn't the normal texture-mapping projection actually work for you?

Determine the X-radius & Y-radius of an ellipse

I need to determine the X-radius & Y-radius of an ellipse give the major & minor radius and I couldn't find any way how to do it.
I have following inputs:
Center Point
Start Point
Major Radius
Minor Radius
So, My question is how to create the ellipse rect that should be passed to GDI api i.e. DrawEllipse to draw the ellipse.
Thanks & Regards,
Pankaj
Google Bresenham + ellipse (and circle since the algorithm is about the same) or see article
http://homepage.smc.edu/kennedy_john/belipse.pdf
Also if you want to have your ellipse in some angle, you might need to draw the ellipse in origo and rotate+translate the point set (e.g. by multiplying the points with suitable matrix)...

Resources