graphics

forwarding (drawing) line in 3d grid

女生的网名这么多〃 提交于 2019-12-17 14:35:52
问题 I need something like Bresenham algorithm but not quite and for 3d grid-space. I got 3d grid of cells (edge size 1.0) need to start in point S and advance to point K 'touching' all the cells the line touches (even if only edge point is touched I need to touch all 8 cells). Need to use it for traversal writing values to the cells or reading values from the cells and need it to be as fast as manageable (it would be in massive use of drawing millions of such 3d grid lines per frame). Could

forwarding (drawing) line in 3d grid

笑着哭i 提交于 2019-12-17 14:35:34
问题 I need something like Bresenham algorithm but not quite and for 3d grid-space. I got 3d grid of cells (edge size 1.0) need to start in point S and advance to point K 'touching' all the cells the line touches (even if only edge point is touched I need to touch all 8 cells). Need to use it for traversal writing values to the cells or reading values from the cells and need it to be as fast as manageable (it would be in massive use of drawing millions of such 3d grid lines per frame). Could

How do you check for intersection between a line segment and a line ray emanating from a point at an angle from horizontal?

不打扰是莪最后的温柔 提交于 2019-12-17 10:46:24
问题 Given a line segment, that is two points (x1,y1) and (x2,y2), one point P(x,y) and an angle theta. How do we find if this line segment and the line ray that emanates from P at an angle theta from horizontal intersects or not? If they do intersect, how to find the point of intersection? 回答1: Let's label the points q = ( x1 , y1 ) and q + s = ( x2 , y2 ). Hence s = ( x2 − x1 , y2 − y1 ). Then the problem looks like this: Let r = (cos θ, sin θ). Then any point on the ray through p is

How to best approximate a geometrical arc with a Bezier curve?

夙愿已清 提交于 2019-12-17 10:36:09
问题 When drawing an Arc in 2D, using a Bezier Curve approximation, how does one calculate the two control points given that you have a center point of a circle, a start and end angle and a radius? 回答1: This isn't easily explained in a StackOverflow post, particularly since proving it to you will involve a number of detailed steps. However, what you're describing is a common question and there's a number of thorough explanations. See here and here ; I like #2 very much and have used it before. 回答2

opengl: glFlush() vs. glFinish()

元气小坏坏 提交于 2019-12-17 10:12:50
问题 I'm having trouble distinguishing the practical difference between calling glFlush() and glFinish() . The docs say that glFlush() and glFinish() will push all buffered operations to OpenGL so that one can be assured they will all be executed, the difference being that glFlush() returns immediately where as glFinish() blocks until all the operations are complete. Having read the definitions, I figured that if I were to use glFlush() that I would probably run into the problem of submitting more

Java: How to draw non-scrolling overlay over ScrollPane Viewport?

落花浮王杯 提交于 2019-12-17 09:51:13
问题 I'd like to use a ScrollPane to display an image in its Viewport, and also have a grid (or box, or any other type of registration/location marker) overlay on the image. I need the overlay to remain fixed when scrolling (meaning the image seems to move "under" the overlay). I will be scrolling the View in the Viewport at a fixed rate to provide a smooth motion, and the overlay is to provide a reference to a certain location within the Viewport. Conceptually, think of a large map scrolling in a

How to shade a region under a curve using ggplot2

柔情痞子 提交于 2019-12-17 09:38:09
问题 I've been trying to use ggplot2 to produce a plot similar to this R graphic: xv<-seq(0,4,0.01) yv<-dnorm(xv,2,0.5) plot(xv,yv,type="l") polygon(c(xv[xv<=1.5],1.5),c(yv[xv<=1.5],yv[xv==0]),col="grey") This is as far as I've gotten with ggplot2: x<-seq(0.0,0.1699,0.0001) ytop<-dnorm(0.12,0.08,0.02) MyDF<-data.frame(x=x,y=dnorm(x,0.08,0.02)) p<-qplot(x=MyDF$x,y=MyDF$y,geom="line") p+geom_segment(aes(x=0.12,y=0,xend=0.12,yend=ytop)) I would like to shade the tail region beyond x=0.12. How would I

Convert Quaternion rotation to rotation matrix?

落花浮王杯 提交于 2019-12-17 09:30:53
问题 Basically, given a quaterion (qx, qy, qz, qw)... How can i convert that to an OpenGL rotation matrix? I'm also interested in which matrix row is "Up", "Right", "Forward" etc... I have a camera rotation in quaternion that I need in vectors... 回答1: The following code is based on a quaternion (qw, qx, qy, qz), where the order is based on the Boost quaternions: boost::math::quaternion<float> quaternion; float qw = quaternion.R_component_1(); float qx = quaternion.R_component_2(); float qy =

Generating a normal map from a height map?

拟墨画扇 提交于 2019-12-17 08:10:00
问题 I'm working on procedurally generating patches of dirt using randomized fractals for a video game. I've already generated a height map using the midpoint displacement algorithm and saved it to a texture. I have some ideas for how to turn that into a texture of normals, but some feedback would be much appreciated. My height texture is currently a 257 x 257 gray-scale image (height values are scaled for visibility purposes): My thinking is that each pixel of the image represents a lattice

Rotate a Graphics bitmap at its center

不羁的心 提交于 2019-12-17 07:52:09
问题 I am working on a project for school, we need to make a basic top down race game in C# without using XNA. First of all let me tell you that the stuff we have learned about programming so far has little to do with making something that even remotely looks like a racegame. It didn't get any more difficult than array's, loops etc. So we didn't learn about graphics or anything like that. Having said all that I am having the following problem. We have created a Graphics object, and then use