3d

Display 3D point using opengl

余生长醉 提交于 2021-01-28 01:14:18
问题 Simply, I am just trying to show a 3d point but nothing show on! How to show it? what is wrong in the code below, anybody can help? init: void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glOrtho(-200, 0.0, -50, 100, 70, 300); } display: void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glPointSize(2); glBegin(GL_POINTS); glVertex3f(-120.0, 25.0, 0.0)

Calculating surface normal in Python using Newell's Method

落花浮王杯 提交于 2021-01-27 19:18:38
问题 I'm trying to implement Newell's Method to calculate the surface normal vector in Python, based on the following pseudocode from here. Begin Function CalculateSurfaceNormal (Input Polygon) Returns Vector Set Vertex Normal to (0, 0, 0) Begin Cycle for Index in [0, Polygon.vertexNumber) Set Vertex Current to Polygon.verts[Index] Set Vertex Next to Polygon.verts[(Index plus 1) mod Polygon.vertexNumber] Set Normal.x to Sum of Normal.x and (multiply (Current.y minus Next.y) by (Current.z plus Next

Basic 3D voxel grid in Mayavi

点点圈 提交于 2021-01-27 10:19:55
问题 I'm trying to visualize a 3D array through Mayavi in Python. I simply want to create a structured 3D voxel grid in which I can show some pre-specified voxel-space-filling points. I do not think that I want The only example that I can find that I think is relatively relevant is this MRI example. I can use the following code to get a somewhat workable example: import numpy as np from mayavi import mlab data = (100, 100, 100) data = np.zeros(data) data[0:50, 50:70, 0:50] = 1 data[0:50, 0:20, 0

How to render OBJ or FBX in Android?

♀尐吖头ヾ 提交于 2021-01-27 06:53:26
问题 I have couple of 3D objects in .obj and .fbx format with included mtl and texture files. I would like to know which is the best library to render those in Android. All I want to achieve is to display the 3D object inside activity, and add touch gestures (drag and pinch zoom). 回答1: After trying both Rajawali and libGDX I can say Rajawali is a bit easier to implement if the intention is not game development. Here is the link to Rajawali library : GitHub Link Their support is really good and

How to render OBJ or FBX in Android?

时光毁灭记忆、已成空白 提交于 2021-01-27 06:51:57
问题 I have couple of 3D objects in .obj and .fbx format with included mtl and texture files. I would like to know which is the best library to render those in Android. All I want to achieve is to display the 3D object inside activity, and add touch gestures (drag and pinch zoom). 回答1: After trying both Rajawali and libGDX I can say Rajawali is a bit easier to implement if the intention is not game development. Here is the link to Rajawali library : GitHub Link Their support is really good and

How to hide invisible elements of the 3d drawing?

女生的网名这么多〃 提交于 2021-01-24 09:52:02
问题 I'm trying to draw a 3d image that displays a ripple: function myFunc(x, y) { let zRipple = Math.pow(2, -0.005 * (Math.abs(x) + Math.abs(y))) * Math.cos(((x * x + y * y) * 2 * pi) / 180 / width) * height; return zRipple; } width and height here are constants that define a drawing area and are equal to 200 in my tests. My approach is based on what I recall from an article that I read 30 years ago and trying to recall now. The idea is to: split the whole drawing board into the 10-pixel grid for

How to hide invisible elements of the 3d drawing?

浪子不回头ぞ 提交于 2021-01-24 09:51:13
问题 I'm trying to draw a 3d image that displays a ripple: function myFunc(x, y) { let zRipple = Math.pow(2, -0.005 * (Math.abs(x) + Math.abs(y))) * Math.cos(((x * x + y * y) * 2 * pi) / 180 / width) * height; return zRipple; } width and height here are constants that define a drawing area and are equal to 200 in my tests. My approach is based on what I recall from an article that I read 30 years ago and trying to recall now. The idea is to: split the whole drawing board into the 10-pixel grid for

Rotating body from spherical coordinates

烈酒焚心 提交于 2021-01-21 09:18:19
问题 Is it possible to rotate body which has its vertices defined in spherical coordinates. Currently I am doing collage project in VHDL and is about rotating dodecahedron and presenting over VGA. I applied pinhole camera model equations and that required just two sin/cos calculation and two multiplication per vertice. I was just thinking about rotating around 3rd axis using 3 steps over two angles but i am unable to figure out proper equations and even if this is possible. Edit I think I got it.

R: “Superimpose” (stack) plots on top of each other (ggplot2, plotly)

孤者浪人 提交于 2021-01-20 12:35:33
问题 I am using the R programming language. I am trying to learn how to plot "non linear decision boundaries", such as the examples seen over here: https://stats.stackexchange.com/questions/212965/how-to-achieve-a-nonlinear-decision-boundary . I am trying to learn how to do this both in 2 Dimensions and in 3 Dimensions. I have figured out how to make the basic plots, but I am still struggling to plot the decision boundaries. To illustrate this example, I have simulated some data. I then split this

How to display coordinate value on the top of a 3D cube three.js

倾然丶 夕夏残阳落幕 提交于 2021-01-07 06:31:37
问题 I am developing a 3D cube with three.js that rotates and translates continously. The 3D cube is rotated using random generated numbers for now (Ultimately the numbers will be coming from an accelerometer and gyroscope). Below is the HTML code: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="css" href="style.css"> <script src="https://threejs.org/build/three.min.js"></script> <script src= "https://threejs.org/examples/js/controls/OrbitControls.js"></script>