Are yRes and xRes declared as int? If that's the case, the division y/x may be 0. Try casting one of the variables to float. In addition, I noticed that you are calculating the aspect ratio using yRes/xRes. If you are using yRes for height and xRes for width, you...

java,3d,libgdx,opengl-es-2.0,perspectivecamera

I would use the Univesal Tween Engine, which is a library for interpolating pretty much anything. You'd have to write a Vector3Accessor class (which would be very simple), but then you'd have all sorts of controls and options for smooth movement. It has a very rich API and is used...

The Box() constructor is meant for serialization only and doesn't initialize the mesh. The constructor in your upper example is deprecated. Use: tower = new Box(0.5f, 0.5f, 0.5f); This will create a cube of the size 1x1x1 centered at [0, 0, 0]. Also, make sure you look at the tower....

The indexed mesh is, by far, the most popular and used by at least Maya, LW, 3DS Max, and Modo. I'm not sure about XSI and Cinema 4D (haven't looked into their SDKs quite as much). Wings3D uses winged edges, as its name implies, as did Mirai and Nendo from...

OpenGL's window space is always defined to have the origin at bottom left corner. Using some projection matrix will not flip this. It will only add a mirroring component to the transformation from eye to clip space (where later window coords are derived from). So if you feed gluUnporject with...

graphics,unity3d,3d,game-engine

If you don't use realtime shadows (it's an option, often on mobile), than you can have more or less 2 approach for dynamic objects: Use lightmap data baked into probes to approximate per-vertex lighting (no need to have realtime light). It's an approximation but can work on some contexts. Use...

matlab,image-processing,plot,3d,surface

Setting those values to NaN should do. Here's an example: [x, y] = ndgrid(linspace(-1,1,500)); z = cos(2*pi*(x+y)*2); z(x.^2+y.^2>1) = NaN; %// remove values outside unit circle surf(x,y,z,'edgecolor','none') colorbar view(2) axis equal ...

unity3d,3d,augmented-reality,movement,gameobject

Instead of playing with ScreenToWorldPoint, you should use a raycast against a plane, see this answer: http://stackoverflow.com/a/29754194/785171. The plane should be attached to your AR marker....

The following MAXScript function demonstrates how to calculate a box2 of the safe frame dimensions, given a point2 of the viewport size and the render size. We need to account for two separate cases: one where the differences in aspect result in spacing on the left and right, and one...

python,matplotlib,plot,3d,surface

Apparently, after some trial and error, the best/easiest thing to do in this case is to just to convert the r, theta, and z data points (defined as 2D arrays, just like for an x,y,z plot) into cartesian coordinates: # convert to rectangular x = r*numpy.cos(theta) y = r*numpy.sin(theta) z...

Here's another way of building patches. You specify a structure with the points (vertices), then the faces (which points do they include), then a vector of color (your sigma values), then you send the lot to the patch function which will take care of the rest. Then you finalise the...

The library (.lib) you are trying to link to seems to be a C++ library, although these functions have C entry points (check with Dependency Walker). I got it to compile by renaming your mexFunction source from .c to .cpp, putting the header and source in the same folder, and...

You can calculate the bounding box of your mesh, and scale it based on the number you get to make it the same size as other objects.

You are defining the variable material in two places, and consequently you are passing MeshBasicMaterial instead of LineBasicMaterial to the THREE.Line constructor. three.js r.71...

matlab,user-interface,3d,rotation,lighting

Implement own rotation functionality You can implement an own functionality to adjust the axes and the lights at the same time. This way the light gets adjusted continuously while rotating the axes. function follow_me_1 figure axes('buttondownfcn', @buttondownfcn); % assign callback set(gca,'NextPlot','add'); % add next plot to current axis surf(peaks,'hittest','off'); %...

web,unity3d,3d,augmented-reality,unity-web-player

Try this. Furthermore, I would just uninstall everything and just reinstall with a stable version of Unity 5.

arrays,image-processing,multidimensional-array,3d,wolfram-mathematica

Your Mathematica syntax is seriously wonky. And you probably shouldn't be using Do, or any other looping construct, in the first place. Let's take some baby steps before we try to walk ... According to the documentation, and my experience, Image3D[{img1,img2}] loads the list of 2D images (the list is...

In function parameters you can omit the length of the first dimension of a multidimensional array. Therefore void play(int board[2][HEIGHT][WIDTH]); is equivalent to void play(int board[][HEIGHT][WIDTH]); You should also know that compiler changes void foo(int arr[]); to void foo(int *arr); i.e. arr is in fact pointer to the first element...

opencv,image-processing,3d,camera-calibration

x, y image point only determines a ray from the camera centers through the image point. It has infinite number of possible z and when you multiply images point with inverse matrices you will get an equation of a ray or a line. It is impossible to get 3D from...

The source file of chartSeries3d should help. Also, you may be interested in the source("http://www.quantmod.com/examples/chartSeries3d/chartSeries3d.alpha.R") library("xts") data("sample_matrix") chartSeries3d0( as.xts( sample_matrix ), col=c("lightblue","blue")) ...

well, I've just had to make: using PyPlot using Distributions function f(x) return (x[1]^2 + x[2]^2) #return sin(x[1]) + cos(x[2]) end n = 100 x = linspace(-1, 1, n) y = linspace(-1,1,n) xgrid = repmat(x',n,1) ygrid = repmat(y,1,n) z = zeros(n,n) for i in 1:n for j in 1:n z[i:i,j:j]...

java,javafx,3d,quaternions,javafx-3d

There's a reason why all those tutorials point to rotational matrices: in 3D you can't perform simultaneous rotations one by one, you need to perform them at once. Since JavaFX only uses one angle and one axis, you have to provide the way to convert three rotations over three axes...

math,matrix,3d,quaternions,rotational-matrices

vec_res = (inverse(VM) * conversion_to_matrix(q) * VM) * vec_input Is perfectly valid. The problem is... inverse(VM) * conversion_to_matrix(q) * VM is NOT equal to conversion_to_matrix(q) Therefore you have to keep the original equation in its entirety....

You can draw points by using GL_POINTS mode if you're running OpenGL ES 1.0 or 1.1, with 2.0+ you need to perform some trickery in order to draw points Apparantly 2.0 supports point sprites too(see comments below), so the simplest answer is to use point sprites You can either draw...

A toon shader is typically used for this. Use the 'Ink 'n Paint' shader on your models, and set it for the kind of look you are after.

You're working in the XY plane, so you can't really rotate around a vector in XY. Instead, you want to rotate along the unit Z axis (glRotate (angle, 0, 0, 1);). Imagine your screen being the XY coordinate system and the Z axis pointing inwards. What you want is to...

c++,3d,directx,direct3d,directx-9

In your code (downloaded), xRes and yRes are ints. Due to integer division, yRes/xRes will be zero, because xRes > yRes. You are passing this into the D3DXMatrixPerspextiveFovLH function as the aspect ratio, which will produce an invalid matrix. Instead, cast them to floats first, before doing the division, and...

Theoretically normals are not really vectors, they are really best though of as bivectors, it just so happens that in 3D both vectors and bivector have three components so it is common to identify they two. If we lived in a four dimensional world we would not have this confusion....

Imagine, instead of a camera, you're moving your head around in 3D space. then Camera.Position is specifying where your head is located, Camera.LookDirection determines the direction you're looking at and Camera.UpDirection shows the orientation of your head. the following pictures clear things up for you. In the first Image, Camera...

I think your error in the 3D vs 2D surface colour is due to data normalisation in the surface colours. If you normalise the data passed to plot_surface facecolor with, facecolors=plt.cm.BrBG(data/data.max()) the results are closer to what you'd expect. Unless you have a strong reason for using imshow, you may...

You can do this using rgl package (interface to openGL) in R and the turn3d function ## Define a function (ys must be positive, we are spinning about x-axis) f <- function(x) 2*exp(-1/2*x) * (cos(pi*x) + sin(pi*x)) + 2 xs <- seq(0, 10, length=1000) plot(xs, f(xs), type="l") ## Rotate about...

First off, have a look at the documentation for the Leap Motion Python API. Then examine the Sample.py program in the SDK samples folder. Sample.py provides an example for getting just about every piece of information available from the API. For your specific problem above, Finger.TYPE_INDEX gives you an enumeration...

Your projection matrix is following the "classic" OpenGL conventions: viewing direction is (0,0,-1) in eye space (last row of the matrix). However, your view matrix does not follow that convention: You must put the negated forward direction into the matrix (also for calculation the translation z component there). In its...

c++,algorithm,3d,marching-cubes

Lots of questions. I am going to try to give some pointers. First of 200^3 is a pretty small dataset for ct! what about 1024^3? :) Marching cubes is built for regular grids. So wether data is defined at cube vertices or centers really does not matter: just shift by...

python,performance,dictionary,3d,pygame

Pygame doesn't have the ability to do this natively. If you really want this, you'll need to brush up on your trigonometry to map lines from the 3D space to the 2D screen. At that point, you'll essentially be re-implementing a 3D engine.

Solution: -just change vtkRenderer with your renderer and vtkViewport with yourviewport void WorldToView(double &x, double &y, double &z) { double coordinates[3]; coordinates[0]=x; coordinates[1]=y; coordinates[2]=z; vtkRenderer->SetWorldPoint(coordinates); vtkRenderer->WorldToView(); vtkRenderer->GetViewPoint(coordinates); x = coordinates[0]; y = coordinates[1]; vtkViewport->ViewportToNormalizedViewport(x,y); } ...

The following describes a way, which should work for your situation. Compute normal in billboard space For example, you could use your texture coordinates here float3 normal = float3(Tex.x*2-1, 0, Tex.y*2-1); normal.y = sqrt(normal.x*normal.x+normal.y*normal.y) Create an orthonormal transformation matrix (World -> Billboard) This matrix consists of the three normalized base...

To add reflection first you need mirror light vector by surface normal all these are unit vectors: l - (yellow) to light source n - (aqua) surface normal r - (green) reflected light direction e - (orange) to eye/camera direction points: p - (red) - rendered pixel position q -...

I'm taking you at your word that you want circles, so you need to push the plot area into the upper right corner: outHalfCirc <- function(r,colr) {opar=par(xpd=TRUE, new=TRUE) #plot ouside plot area polygon(x=seq(r,-r,by=-0.1), y= -sqrt(r^2 - seq(r,-r,by=-0.1)^2) , # solve r^2 = x^2 +y^2 for y xlim =c(0,7 ), ylim=c(0,10),...

You could do the following: library(scatterplot3d) a<-c(1:10) b<-c(1:10) c<-c(1:10) #remove x labels using x.ticklabs = '' scatterplot3d(a,b,c, main="3-D Scatterplot",color="blue", pch=19, type="h", lty.hplot=2, box=F, scale.y=.5, lty.grid=1, lab=c(9,5,1), xlab="", ylab="", zlab="", x.ticklabs='') #add the labels using the text function. srt specifies the angle. text(x=b, y=1, pos=1, labels=b, srt=45, adj=1, xpd=TRUE, offset=0.5) And...

c++,opengl,3d,textures,texture-mapping

acos (dot ( N, L )) gets the angle between the vectors N and L this will be in radians so it needs to be divided by pi to get in the range texture() expects. All the actual texturing magic happens here fragColor = vec4 (texture (texture1, vec2 ( theta,...

javascript,html5,canvas,3d,rotation

To fake it you could render the 3D animation of a rotation in a single direction. Like this: Then calculate the direction vector and rotate the sprite based on the angle....

For the first part, related to JavaFX 3D, I suggest you have a look at the FXyz library. You will find a extense library of custom shapes like: Cone, Pyramid, SegmentedSphere, Spheroid, Torus, SegmentedTorus, Prism, Spring, CurvedSpring, Frustum, Icosahedron, Knot,... Also, have a look at the sampler application, where you...

Generate the points in the straight position then apply the rotation (also check the origin of the coordinates).

If you want to get the pitch, yaw and roll angles at any stage after several rotations, you can get them from the transformation matrix of the 3D model. If you have a look at the transformation matrix after several rotations: Transform T = model3D.getLocalToSceneTransform(); System.out.println(T); you'll see something like...

On my system (OSX 10.7.5, R 3.1.2) I get an alpha as xlab with: require(rgl) plot3d(1,1,1,xlab=intToUtf8(0x03B1L) ) And pasting to ordinary text also succeeds: plot3d(1,1,1, xlab=paste("Lyman ", intToUtf8(0x03B1L) ) ) ...

javascript,highcharts,3d,scatter-plot

Here are two methods, which both are not ideal in my opinion, but get the job done given that your chart is somewhat static in it's appearance (width and height). Set margins to make the plot area reflect the dimensions of the axis. In your case 1:1 for x and...

Using some simulated data this should get you what you want. The key is that you have to create your bivariate bins, accomplished using the cuts() function. Then treating the binned factors as levels we can then count the combinations of each factor level using the table() function: library(plot3D) ##...

You can use conditional plotting. splot 'data.txt' u ($1==6 ? $2:1/0):3:4 title 'At-no 6' w points pt 7, \ 'data.txt' u ($1==7 ? $2:1/0):3:4 title 'At-no 7' w points pt 7, \ 'data.txt' u ($1==1 ? $2:1/0):3:4 title 'At-no 1' w points pt This creates ...

Here's a solution, but you'll have to change the test to something other than pDist1 > pDist2: segmentAngle = (math.pi * 2) / numberOfSides pRawAngle = math.atan2(y, x) pAngle = abs((pRawAngle % segmentAngle) - (segmentAngle / 2)) pEdgeAngle = pRawAngle - pAngle pDistanceToEdge = radius * (math.cos(segmentAngle / 2) *...

If you are referring to rotating an image during a Swing paint operation, then the correct way to do this is with an AffineTransform. Graphics2D graphic; graphic.drawRenderedImage(image, AffineTransform.getRotateInstance(Math.PI)); Unfortunately AffineTransform does not support perspective transforms (by definition a transform is only Affine if parallel lines remain parallel). For perspective transforms...

qt,3d,pyqt,2d,2d-3d-conversion

To answer my own question: (x, y, z, vx, vy, vz) = self._display.View.ConvertWithProj(self.lastPos.x(), self.lastPos.y()) Gives the entire line of points that x and y can map to, with x, y, and z being one point, and vx, vy, and vz giving the parameterization of the line....

plot,3d,gnuplot,surface,scatter3d

You can do the calculations inside gnuplot's using statement. For the lines I use the vectors plotting style, and with arrowstyle variable (or linecolor variable) you can select different colors depending on the dz value: set style arrow 1 linecolor rgb 'red' nohead set style arrow 2 linecolor rgb 'green'...

Your approach is almost correct, but you are failing at updating the info of the faces array. With every volume section you add, you add new vertices to the final mesh, so the vertices indices on the face array should be shifted accordingly. For that, keep a counter of the...

algorithm,3d,geometry,distance,computational-geometry

Find affine transform M that translates this ellipse in axis-oriented one (translation by -p and rotation to align orientation vector r and proper coordinate axis). Then apply this transform to point p and check that p' lies inside axis-oriented ellipsoid, i.e. x^2/a^2+ y^2/b^2+z^2/c^2 <= 1

By flipping around the y-axis you flipped the chirality of the world space. Which means that the winding of your faces comes out differently. CCW becomes CW and vice versa. Most likely you have face culling enabled, so to account for the chirality flip you have to swap CCW for...

Use Renderer.isVisible method on these tiles renderers.

You missed one line on the Wikipedia page where So add this line n0 = n / norm(n); and change the final line to L = ((n0*A)-d); ...

python,matplotlib,plot,3d,surface

Even if I agree with the others that meshgrids are not difficult, still I think that a solution is provided by the Mayavi package (check the function surf) from mayavi import mlab mlab.surf(Z) mlab.show()...

What you're looking for are constructive solid geometry/boolean algorithms with arbitrary meshes. It's considerably more complex than slicing meshes by an infinite plane. Among the earliest and simplest research in this area, and a good starting point, is Constructive Solid Geometry for Polyhedral Objects by Trumbore and Hughes. http://cs.brown.edu/~jfh/papers/Laidlaw-CSG-1986/main.htm From...

A possible solution could be: to define a matrix of colour indeces: since you need 9 colours it should be a (9 x 3) matrix to use the value stored in the 5th column of your data to select the color in the color matrix (i. e. to select the...

javascript,3d,three.js,intersection

You can take a look at http://www.realtimerendering.com/intersections.html. Even though the site is from 2011 the intersection algorithms have not changed in the last years. From the demo it seems that once the polyhedrons are placed in the cube, they don't move. So the SAT algorithm would not be the best...

I don't know why it didn't work the way you coded, but I could get it to work like this: import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import time import numpy count=0 fig = plt.figure() ax = fig.gca(projection='3d') z = [0] x = [0] y...

gluLookAt() multiplies by the current matrix, it does not load a new one. Multiple gluLookAt()s multiplied together aren't very meaningful. Reload proj/modelview matrices each frame, helps prevent matrix oddities. Let GLUT do it's job, don't call display() from idle(), use glutPostRedisplay() instead. That way GLUT knows to call display()...

c++,opengl,3d,shadow,shadow-mapping

ShadowCoord = ProjectionMatrix * ShadowMatrix * WorldMatrix * vec4 (VertexPosition, 1); This calculates the position of this vertex within the eye space of the light. What you're recomputing is what the Position = ProjectionMatrix * ViewMatrix * WorldMatrix * vec4 (VertexPosition, 1); line must have produced back when you were...

update after further clarifications and chat The whole proint is that 3D transformatins are not commutative. This means that translating and then rotating is different that rotating and then translating (will produce different results). In some special cases these can coincide (e.g origins are at 0,0,0 and so on..), but...

You want to create cylinder and point it in a particular direction. One way to do that is to use the following pattern: Create the geometry. var cylinderGeometry = new THREE.CylinderGeometry( 1, 10, 25, 4, 1 ); Translate the geometry so the base sits at the origin. cylinderGeometry.applyMatrix( new THREE.Matrix4().makeTranslation(...

The real answer to your question is that you're thinking about it a bit sideways: you shouldn't be using an applet (they're dead), and you shouldn't try to do it all by yourself without any libraries. I'd personally recommend Processing for beginners or libGDX for more experienced users. They both...

The proper formulas would be x = Math.cos(alpha)*Math.cos(beta); z = Math.sin(alpha)*Math.cos(beta); y = Math.sin(beta); ...

You should use labels.append instead of numpy.append Example code - labels = [] for line in lines: lab = [h/100, maxf, title] labels.append(lab) Also this would create the labels list as - [[1,34,u'te],[2,44,u've],[4,43,u'ht]] [1,34,u'te],[2,44,u've],[4,43,u'ht] is not possible in python, these are either three different lists, or they are enclosed by...

You are using the "matrix * vector" multiplication order in your shader. You must build your matrices following this convention. OpenGL will use column major order for matrices, so your setPosition function creates a matrix where it put the x and y translation parts into the last row instead of...

The color RGB vector is multiplied by the shade coefficient (the cosine value as you initially assumed) The logarithmic scaling is done by the target imaging device and human eyes If your colors get too dark then the probable cause is: the cosine or angle value get truncated to integer...

Actually i found out the problem. The file .png containing the texture, wasn't actually a real .png file. Opening it and re-saving it with Gimp solved my problem. It took me a while to solve this problem, since the file wasn't corrupted, considering that i could open it without any...

It is not working because you are sending the second parameter to the OrbitControls. This for some reason seems to stop the end event being fired. controls = new THREE.OrbitControls( camera, renderer.domElement ); Without out it it seems to work as expected: controls = new THREE.OrbitControls( camera ); I have...

Use surf(Y,X,Z) From the documentation (emphasis added): surf(x,y,Z) and surf(x,y,Z,C), with two vector arguments replacing the first two matrix arguments, must have length(x) = nand length(y) = m where [m,n] = size(Z). In this case, the vertices of the surface patches are the triples (x(j), y(i), Z(i,j)). Note that x...

c++,opengl,3d,drag-and-drop,mouse-picking

I'm used to solving these user-interaction problems somewhat naively (perhaps not in a mathematically optimal way) but "well enough" considering that they're not very performance-critical (the user interaction parts, not necessarily the resulting modifications to the scene). For unconstrained free dragging of an object, the method you described using unproject...

Well, as Vincent said, it seems that there's no way to do that as simple as with glut. But we can do that with more code. Spektre contributed a way in his comment. This is a way I found to do that using the sphere's parametric equation: import org.lwjgl.glfw.*; import...

It's because you haven't specified normals for your custom figure. You also need to do: geometry.computeFaceNormals (); geometry.computeVertexNormals (); ...

opencv,image-processing,3d,computer-vision,camera-calibration

This can be done in pure OpenCV as long as you have your camera parameters. You should be able to create three vectors corresponding to axis x, y, z (basically points [0,0,0] [1, 0, 0], [0, 1, 0], [0, 0, 1] which you will later project into the image plane....

I solved my own problem. The reason is that I mixed up two versions of OpenSceneGraph, one is compiled with VS2012 without JPEG plugin and the other is compiled with VS2010 with JPEG plugin. The OSG compiled with VS2010 will not work under VS2012. Now I've found another OSG compiled...

Welp, i fingered it out myself! #cube { width:500px; height:150px; background: linear-gradient(45deg, black 0%, black 43%, transparent 43%, transparent 60%, black 60%, black 100% ), linear-gradient(-45deg, black 0%, black 43%, transparent 43%, transparent 60%, black 60%, black 100% ), linear-gradient(90deg, black 0%, black 44%, transparent 44%, transparent 56.5%, black 56.5%,...

Okay. From your code, I'm not too sure what you want the final product to look like, or what you want to do with the heights. But I made an example that uses the 1s and 0s of the map to draw or not draw wall sections on the canvas....

If you are okay with using contour or contourf, you can do something like this: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # Prepare sample data - normally distributed NSamples = 5000 vmin, vmax = -2, 2 X = np.random.normal(loc=-.1, scale=.5, size=(NSamples,)) Y = np.random.normal(loc=.1,...

I fixed it! First thing I had to do was add my buffer binding and attribute pointing into the while loop, I guess you have to tell opengl about them every time you call useProgram. The second thing was I needed to call glUniformMatrix4fv if I wanted to pass my...

I'm assuming you're using a perspective projection and you near plane is greater than one. This would lead to the following scenario where the geometry is behind the near plane and gets clipped: Simply reduce the near plane to 0.1 for example. But make sure not to make it too...

css,3d,seo,transform,googlebot

To check what Google's robots see, you should not rely on cache, but on the 'Fetch as Google' feature from Google Webmaster Tools. Cache lags behind the index (sometimes a lot). Your 'if you hide it, it won't count' rule is not correct. It's: 'if it is never displayed to...

The question is too general and I cannot be sure about the meaning of the matrix in every context. However, mathematically, when you represent a coordinate system with a matrix, the matrix is the one you use to change a vector from that coordinate system to the so called canonical...

I see you also created a github issue. That's the right place to ask this.

You don't need some environment geometry at all. All you need to do is drawing a full screen quad, and just compute the correct texture coordinates for it. Now with modern GL, we don't even need to supply vertex data for this, we can use attributless rendering: Vertex Shader: #version...

Qt has a tutorial on importing and displaying 3ds models. It's not exactly what you wanted, since it does not operate with array of 3d point coordinates, but how about editing the model in Maya/Blender/anything else that can export 3ds and loading it this way? Moreover (I haven't tried this,...

Finally figured out how to do it, thanks to @dominik! Here is my solution: var importer = new HelixToolkit.Wpf.ModelImporter(); var point = importer.Load("hand.obj"); GeometryModel3D model = point.Children[0] as GeometryModel3D; DiffuseMaterial material = new DiffuseMaterial(new SolidColorBrush(Colors.Black)); model.Material = material; ...

javafx,3d,transparency,transparent,javafx-3d

Transparency in JavaFX 3D shapes has been a long time request... until recently: Since JDK8u60 early access release b14, transparency is enabled in 3D shapes. You can add color with transparency as diffuse color, like in this answer. Also you can add images with some transparency level on every pixel,...

opengl,3d,directx,gaming,3d-modelling

Terrain generation is highly dependent on the game's requirements, not necessarily on the advantages and disadvantages of a particular generation method. There are essentially three categories of approaches which are widely used, which may be combined for a final solution: Modelled in DCC tools (potentially using terrain generation plugins), and...

image,matlab,image-processing,3d

For applying imadjust for set of 2D grayscale images taking the whole value into account, this trick might work a = imread('pout.tif'); a = imresize(a,[256 256]); %// re-sizing to match image b's dimension b = imread('cameraman.tif'); Im = cat(3,a,b); %//where a,b are separate grayscale images of same dimensions %// if...