Calculate GPS location with center point - algorithm

I got one center point GPS such as(32.112342,112.223123)
and I got radius 10(km)
I can draw a circle with these information
Here I have one new requirement
I need fix this circle with little Hexagon.
and the center Hexagon must be the the center of the circle
how can I get all those little Hexagon's center point GPS location
Thans

Suggest you to try with Graphics2D as provided in java.awt package.
You can use its drawPolygon() and fillPolygon() methods.

Related

Convert screen space X,Y position into perspective projection with a specific z position

I'm using ThreeJS, but this is a general math question.
My end goal is to position an object in my scene using 2D screen space coordinates; however, I want a specific z position in the perspective projection.
As an example, I have a sphere that I want to place towards the bottom left of the screen while having the sphere be 5 units away from the camera. If the camera were to move, the sphere would maintain its perceived size and position.
I can't use an orthographic camera because the sphere needs to be able to move around in the perspective projection. At some point the sphere will be undocked from the screen and interact with the scene using physics.
I'm sure the solution is somewhere in the camera inverse matrix, however, that is beyond my abilities at the current moment.
Any help is greatly appreciated.
Thanks!
Your post includes too many questions, which is out of scope for StackOverflow. But I’ll try to answer just the main one:
Create a plane Mesh using PlaneGeometry.
Rotate it to face the camera, place it 5 units away from the camera.
Add it as a child with camera.add(plane); so whenever the camera moves, the plane moves with it.
Use a Raycaster’s .setfromCamera(cords, cam)
then
.intersectObject(plane)
method to convert x, y screen cords into an x, y, z world position where it
intersects the plane. You can read about it in the docs.
Once it’s working, make the plane invisible with visible = false
You can see the raycaster working in this official example: https://threejs.org/examples/#webgl_geometry_terrain_raycast

Is there any difference between hololens' viewport and UE4's viewport?

Our main idea is that we take a picture by hololens then we get the 2D coordinates of something(the thermos and the printer) in this picture. Then we deproject these two things' 2D coordinates of their screenshot back to 3D coordinates in the unreal world, then we draw a box at coordinates' position.
However, as you can see, we marked the thermos(the first picture) and the printer(the second picture) with the 3D coordinates we calculated from their coordinates in their 2D screenshot with a static mesh. But, they have an obvious offset to left down. We speculate that maybe such kind of problem comes from the reason that our camera center is wrong.
Did you meet or solve such kind of problem? Can you give me some advice? Thanks a lot.
We noticed that you already have a new one with more information in Microsoft Q&A community platform. It seems like where exactly is returned from GetActorLocation is headset position and there is an offset from location of PV camera. So that, it is recommended you using the GetPVCameraToWorldTransform API which in HoloLensARFunctionLibrary.h header file to find the camera position in World Space. And then GetWorldSpaceRayFromCameraPoint can help to find what exists in world space at a particular pixel coordinate. For more detail about how to implement this solution, please go through this section: Find Camera Positions in World Space

How to rotate an image x degrees then move in that direction?

I'm a newbie to KineticJS and have been going through the tutorials. I want to take an image that has a 'front' and rotate it a random number of degrees and then have it move forward a number of pixels/inches in that new direction.
I was able to use this rotation tutorial to rotate my image.
I see how to use transitionTo to send an image to an x/y coordinate.
I'm having trouble tying the two together. I feel like I need randomly generate e a new x/y coordinate and then determine the degree difference between where my image is pointing and a line drawn from the center of the image to the new x/y point.
Does anyone have any tips for doing something like this? How would one draw two lines from one point and determine the angle between them?
Thanks in advance.
You have to calculate the new coordinates thanks to the law of cosines.
http://en.wikipedia.org/wiki/Law_of_cosines
Once you have calculated the angle, you have to be careful because you will get an absolute angle.
Don't hesitate if you need more help. I also have to do this calculation using KineticJS.
Good luck !
The JS Math Object will be useful I guess : http://www.w3schools.com/jsref/jsref_obj_math.asp

Getting coordinates of the mouse in relation to 3D space in THREE.js

I have struggled for the past 3 weeks trying to figure this out. If anyone could help me I would appreciate it so much.
I'm developing a game similar to Geometry Wars in where I have a triangle in the middle of the screen which you can move around.
The problem is I need the triangle to rotate and face toward the direction of the mouse curser. I don't need to worry about the z-axis per-say as I always have the camera in a fixed position (z=500) and I am treating the scene as a "2D scene" - all the action occurs on the z=0 plane.
Calculating the angle between the triangle and the mouse is elementary:
targetAngle = Math.atan2(mouseCoord.y-this.position.y, mouseCoord.x-this.position.x)
where this is the mesh.
The problem is that the mouseCoords are in standed Dom window format whilst the position of the triangle is in Three.js format.
Q) How would I convert the mouse coords to represent the coords on the z=0 plane where the triangle is?
I have tryed so many ways including ray intersection but nothing works ;(
Thank you all for your help and thank you so much for an amazing framework!!!!
I don't actually see the problem. use the THREE.vector3 with the z coord in 0. then use something like triangle.rotate(THREE.vector3(targetAngle,0,0) or something
I suspect your intersection isn't working because of a CSS offset by your canvas within the DOM.
If you need the triangle to look at something specific, you should simply be able to use the "lookAt" method of the triangle.
To have it look at the camera for example:
triangleMesh.lookAt(camera.position);

Rotating an NSView and getting its corner points

I am rotating an NSView using:
setFrameRotation:
Which rotates the view around its bottom left corner. What is the best way to rotate a view around its center point?
Also, i want to get the points in the superview of its corners. Using:
view.frame.origin
Just gives me the corner before i rotate it. How would i get the actual points of its corners once it has been rotated?
Thanks in advance, Ben
To get an effective rotation about the center of the frame, you have to translate the frame's origin.
Also, of course view.frame.origin gives the origin before you rotate it. It's also giving you the origin after you rotate it, because the rotation is around the origin. The origin isn't moving. If you do translate the origin to get rotation around the center, you'll then know the new origin.
To get the other corners, you'd use [view convertPoint:pt toView:view.superview], where pt is each of the corners in the view's coordinate system. E.g. NSMakePoint(NSMaxX([view bounds]), NSMinY([view bounds])).
You can actually use this technique to obtain the translation you want. Compute the desired center of the view, or just record the current center if it's where you want it. Then rotate the view. Obtain the new location of the center using -convertPoint:toView:. Then translate the origin by the difference between the new center and the desired center.

Resources