3d

Rotating Towards Path in OpenGL

你离开我真会死。 提交于 2020-01-03 03:42:08
问题 I am having trouble on how to rotate an object in 3D space, based on the OpenGL rotate function glRotatef(..). glRotatef ( angle , x , y , z ) My object is traveling from one point to another in 3D space. I want my object to rotate in the direction it is traveling. How would I find the angle, x, y, z that is needed for the glRotatef(...) function if I know the point where I am starting and the point where I am finishing. 回答1: The gluLookAt function is exactly what you need here. It will save

How to rotate an object around a custom pivot in JavaFX?

自作多情 提交于 2020-01-03 03:39:05
问题 I want to rotate an object round a custom pivot, which is its point, so I have such code: private final EventHandler<MouseEvent> mouseEventHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getEventType() == MouseEvent.MOUSE_PRESSED) { dragStartX = mouseEvent.getSceneX(); dragStartY = mouseEvent.getSceneY(); mousePosX = mouseEvent.getSceneX(); mousePosY = mouseEvent.getSceneY(); mouseOldX = mouseEvent.getSceneX(); mouseOldY =

How do I color individual sections of a 3d sphere in Python

眉间皱痕 提交于 2020-01-03 03:33:06
问题 I have created a 3d plot of a sphere in python using Mathplotlib using the code below from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from matplotlib import cm fig = plt.figure() ax = fig.add_subplot(111, projection='3d') u = np.linspace(0,2*np.pi, 32) v = np.linspace(0, np.pi, 16) x = 10 * np.outer(np.cos(u), np.sin(v)) y = 10 * np.outer(np.sin(u), np.sin(v)) z = 10 * np.outer(np.ones(np.size(u)), np.cos(v)) ax.plot_surface(x, y, z, rstride=4,

plotting a sphere in python for an orbital trajectory

僤鯓⒐⒋嵵緔 提交于 2020-01-03 03:32:09
问题 How can I put a sphere of radius 1737 at the location of (384400,0,0) ? This sphere would be the moon in my trajectory. Everything else with the code is fine, I just don't know how to add a sphere in that location with that radius. import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D me = 5.974 * 10 ** (24) # mass of the earth mm = 7.348 * 10 ** (22) # mass of the moon G = 6.67259 * 10 ** (-20) # gravitational parameter

Binary space partition tree for 3D map

萝らか妹 提交于 2020-01-03 03:09:15
问题 I have a project which takes a picture of topographic map and makes it a 3D object. When I draw the 3D rectangles of the object, it works very slowly. I read about BSP trees and I didn't really understand it. Can someone please explain how to use BSP in 3D (maybe give an example)? and how to use it in my case, when some mountains in the map cover other parts so I need to organize the rectangles in order to draw them well? 回答1: In n-D a BSP tree is a spatial partitioning data structure that

Implement Google 3D maps for my Android app?

自作多情 提交于 2020-01-03 03:03:08
问题 is it possible to use the new Google 3D Maps for Android in my app? I'm developing an app and I want to add this. thanx! http://www.google.com/mobile/maps/3d/ 回答1: We have created this one: Nutiteq 3D Maps SDK. This is a SDK, not application, so you can use it in your apps as replacement of Google Maps SDK. 回答2: You can't. The Google Maps application no longer uses the same SDK MapView that we third-party developers use. Someday, perhaps they will update it, and then 3D maps will be possible,

Pose estimation of 2nd camera of a calibrated stereo rig, given 1st camera pose

微笑、不失礼 提交于 2020-01-02 16:16:10
问题 Using opencv I've calibrated a pair of cameras in stereo. This results in a Rotation and Translation between the two cameras. I take an image using the 1st camera (left) and use solvePnp to calculate the pose (rvec and tvec) of the left camera relative to a part. My question is how to I calculate the pose of the right camera using the pose of the left camera, and the given R & T values from the stereo calibration? Thanks. 回答1: The question is a bit unclear, but I think that you would like to

Flipping issue when interpolating Rotations using Quaternions

有些话、适合烂在心里 提交于 2020-01-02 10:17:54
问题 I use slerp to interpolate between two quaternions representing rotations. The resulting rotation is then extracted as Euler angles to be fed into a graphics lib. This kind of works, but I have the following problem; when rotating around two (one works just fine) axes in the direction of the green arrow as shown in the left frame here the rotation soon jumps around to rotate from the opposite site to the opposite visual direction, as indicated by the red arrow in the right frame. This may be

Convert 2 3D Points to Directional Vectors to Euler Angles

廉价感情. 提交于 2020-01-02 10:15:47
问题 Here's essentially my problem. Also maybe I am not familiar enough with Euler angles and what I'm attempting to do is not possible. I have 2 points in 3d space. p1 (1,2,3) p2 (4,5,6) In order to get the unit vectors for these two points I'm doing this basically. var productX = (position.X2 - position.X1); var productY = (position.Y2 - position.Y1); var productZ = (position.Z2 - position.Z1); var normalizedTotal = Math.sqrt(productX * productX + productY * productY + productZ * productZ); var

Get points enclosed by a 3d polygon

断了今生、忘了曾经 提交于 2020-01-02 09:28:15
问题 I have a polygon that lies on a 3D plane. i want to get all points enclosed by this polygon.can anyone help me ? i can make a 3D scan line algorithm by replacing the scan lines by planes and get the intersection of planes with my polygon but i want a faster solution. Thanks in advance. 回答1: "yes it's a convex 3p polygon ,but it all its points lie in the same plane" In that case - just convert the polygon and all the test points into 2D local coordinates of the plane and use a 2D algorithm: 2D