transformation

Three.js: chaotic mesh rotation after applyMatrix

两盒软妹~` 提交于 2019-12-08 07:56:58
问题 After applying a matrix to mesh I print its rotation parameters. After resetting mesh rotation, scale and position and re-applying the same matrix - rotation parameters aren't equal to previous ones. var ctm1 = new THREE.Matrix4(); var ctm2 = new THREE.Matrix4(); ctm1.set(...............); ctm2.set(...............); function reset(mesh) { mesh.position.set(0,0,0); mesh.scale.set(5,5,5); mesh.rotation.set(0,0,0); } reset(myMesh); myMesh.applyMatrix(ctm1); console.log(myMesh.rotation.x); reset

Resize viewport, crop scene

别等时光非礼了梦想. 提交于 2019-12-08 06:05:25
问题 I have a 3d scene drawn by OpenGL to a resizeable window. Now, when the window gets resized, I do not want to scale the viewport, rather I want to keep the scene at a fixed size and show a larger portion of it (or crop the scene image). This is my current code: GLfloat ratio; // Protect against a divide by zero if ( height == 0 ) height = 1; ratio = ( GLfloat )width / ( GLfloat )height; // Setup our viewport. glViewport( 0, 0, ( GLint )width, ( GLint )height ); // change to the projection

Gauge chart using D3

陌路散爱 提交于 2019-12-08 03:50:36
问题 I've been trying to build a gauge using d3 and ive managed to hack up something that meets the visual requirements http://bl.ocks.org/ameyms/9140907 This is however a very very hacky solution since ive positioned the needle by trial and error and the whole thing breaks if height and width are assigned percentage values. So how do I position it? Also, how I can make the needle rotate? Any ideas? 回答1: For anyone coming here looking for answers, I have created a demo of gauge using D3 here 来源:

OpenCV getPerspectiveTransform and warpPerspective Java

二次信任 提交于 2019-12-08 03:22:12
问题 I current have a ArrayList<MatOfPoint> which stores the contours of the image and have retrieved the largest contour which is my target for the warpPerspective. List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); Imgproc.findContours(matOut, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); sort(contours); MatOfPoint2f m2f = MatOfPoint2f(contours.get(0).toArray()); double arc = Imgproc.arcLength(m2f, true); MatOfPoint2f approx = new MatOfPoint2f(); Imgproc

How to use `xsl:include` with apache fop

…衆ロ難τιáo~ 提交于 2019-12-08 00:21:28
问题 I use apache FOP to generate pdf files. I have this xsl code <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <fo:root font-size="11pt" font-family="serif"> <fo:layout-master-set> <fo:simple-page-master master-name="A4-portrait" page-height="29.7cm" page-width="21.0cm" margin-top="1cm" margin-left="1.5cm" margin-right="1cm" margin-bottom="1cm"> <fo

Skew, size and rotate a rectangle to fit triangle perfectly

廉价感情. 提交于 2019-12-07 19:09:54
问题 I'm trying to make half of a rectangle - devided diagonally - to fit inside a triangle. Rotation works well, so does sizing of the rectangle. But once I try to skew it, it all gets messed up. Basically I want to simulate a 3D surface. That means I have to find the angle of abc, where b is the center point. And then apply this angle as a skew to the rectangle. But for some reason that doesn't work as intended. Here is a simple illustration of what I want to accomplish: You will probably

J2ME like Sprite on Android

一世执手 提交于 2019-12-07 10:33:15
问题 For my useless project of the month I'm working on a 'emulator' to run J2ME programs on Android. But now I'm stuck with the J2ME Sprite implementation. Specifically the transformations used in it. In my Sprite I have a bitmap with three character images. I would like to paint the second frame mirrored or rotated 90 degrees. What would be the best way for it? I have following code that paints the given frame without any transformations. frameX, frameY are frame position coordinates on give

AST from c code with preprocessor directives

孤人 提交于 2019-12-07 07:03:25
问题 How can I build an AST (Abstract Syntax Tree) from gcc C code in order to make some transformations, like below, and reproduce(generate) the code to C syntax again after that? if(condition_1){ //lines of code 1 } #ifdef expression_1 else if(condition_2){ //lines of code 2 } #endif into bool test = condition_1; if(teste){ //lines of code 1 } #ifdef expression_1 if(!(test) && condition_2){ //lines of code 2 } #endif 回答1: GCC itself will build ASTs, but not before expanding the preprocessor

mayavi - setting the [x,y,z] extent of an image programatically

心不动则不痛 提交于 2019-12-07 06:45:50
问题 I have some data that consists of several 2D images that I would like to render in specific [x,y,z] positions relative to one another using mayavi2 (v4.3.0) . From the documentation it seems that I should just be able to do this with mlab.imshow() . Unfortunately, mayavi throws an exception when I call imshow specifying the extent parameter ( AttributeError: 'ImageActor' object has no attribute 'actor' ). I also tried setting the x,y and z data directly by modifying im.mlab_source.x,y,z... .

Translate image by very small step by OpenCV in C++

天大地大妈咪最大 提交于 2019-12-07 06:11:56
问题 I'm doing image translation by very small step sizes (like translate in column by 1/1024) Consider I have the following image (I create the image with "Mat" in opencv and with the type CV_64F): 255 0 0 0 Now by doing translation in column by (1/1024) I would expect the following: 254.7509765625 0.2490234375 0 0 But what I get is the same source image!: 255 0 0 0 How can I get the expected result? Here is the code I'm doing the translation: Mat sourceImg = (Mat_<double>(2, 2) << 255.0, 0, 0, 0