transformation

Transform to NDC, calculate and transform back to worldspace

谁都会走 提交于 2019-12-11 00:06:36
问题 I have a problem moving world coordinates to ndc coordinates than calculate something with it and move it back inside the shader. The Code looks like that: vec3 testFunc(vec3 pos, vec3 dir){ //pos and dir are in worldspace, convert to NDC vec4 NDC_dir = MVP * vec4(dir,0); vec4 NDC_pos = MVP * vec4(pos,1); NDC_dir /= NDC_dir.w; NDC_pos /= NDC_pos.w; //... do some caclulations => get newPos in NDC //Transform newPos back to worldspace vec4 WS_newPos = inverse(MVP) * vec4(newPos,1); return WS

Apache PDFBox rotate PDImageXObject

你。 提交于 2019-12-10 21:36:57
问题 I'm playing around with the 2.0.0-SNAPSHOT, and I want to set the page to landscape and also rotate my picture. So I've done page.setRotation(90); There seems to be a bug with using PDFBox and AffineTransform This code doesn't do anything like I'd expect: AffineTransform at = new AffineTransform(w, 0, 0, h, 20, 20); at.translate(0.5, 1); at.rotate(Math.toRadians(90)); Width and Height have to be tiny to keep the image on the page, rotate by itself squishes the image, and translate before

What are the different approaches for transforming XML with Java?

我与影子孤独终老i 提交于 2019-12-10 20:12:30
问题 I´m researching how to transform XML from one format to another in a Java project. What alternatives are there and what are their pros and cons? Alternatives I´ve found so far: XSLT/XQuery XML-binding both formats to Java and do the mapping in Java Groovy 回答1: If you're transforming XML to XML, then you'll only make extra work for yourself if you go via a non-XML representation (such as Java objects). Using a high-level declarative language is the way to go, and that means XSLT or XQuery. In

Define PHP-Function in XSL and calling it. Possible? How?

南楼画角 提交于 2019-12-10 16:37:55
问题 Like the title tells: Is it possible to write a PHP-Function in a XSL-Document and call it afterwards? I have no case, where I wanna do that. Its just a thing it came into my mind while learning XSL. In XSL you can compose something like: <xsl:processing-instruction name="php"> ...some php... </xsl> The PHP code will be run in your rendered page. Is it possible to create e.g. a PHP Function in the processing-instruction and call it later (in the same template)? Pseudo-Sample: <xsl:template>

JavaFX How do I scale the coordinates of a Path without altering the line width?

微笑、不失礼 提交于 2019-12-10 16:36:05
问题 I am currently working on a step line chart with a zoom and panning functionality. Since the amount of data I need to process is pretty large, i can not afford to recreate the whole path of the step line, every time layoutPlotChildren() is called. So my idea was to create the path element once and just transform it on zoom an pan events. So far everything worked out as planned, but i am having a big problem when I'm trying to scale the path. Since the Path class is inherited from Shape,

XSLT Filter result using XSLT array

前提是你 提交于 2019-12-10 16:17:57
问题 I am a beginner in XSLT. Below is source XML which i receive. Request tag constains the FlightId which is being used to filter the Result tag. Source XML: <Response> <Request> <RequestedFlights> <FlightId>2121</FlightId> <FlightId>2584</FlightId> </RequestedFlights> </Request> <Result> <Flights> <Flight> <Segments> <Segment> <Id>1</Id> <FlightNumber>2121</FlightNumber> </Segment> <Segment> <Id>2</Id> <FlightNumber>1121</FlightNumber> </Segment> </Segments> </Flight> <Flight> <Segments>

sklearn mask for onehotencoder does not work

社会主义新天地 提交于 2019-12-10 15:29:04
问题 Considering data like: from sklearn.preprocessing import OneHotEncoder import numpy as np dt = 'object, i4, i4' d = np.array([('aaa', 1, 1), ('bbb', 2, 2)], dtype=dt) I want to exclude the text column using the OHE functionality. Why does the following not work? ohe = OneHotEncoder(categorical_features=np.array([False,True,True], dtype=bool)) ohe.fit(d) ValueError: could not convert string to float: 'bbb' It says in the documentation: categorical_features: “all” or array of indices or mask :

Checking if Two Massive Python Dictionaries are Equivalent

删除回忆录丶 提交于 2019-12-10 12:50:02
问题 I have a massive python dictionary with over 90,000 entries. For reasons I won't get into, I need to store this dictionary in my database and then at a later point recompile dictionary from the database entries. I am trying to set up a procedure to verify that my storage and recompilation was faithful and that my new dictionary is equivalent to the old one. What is the best methodology for testing this. There are minor differences and I want to figure out what they are. 回答1: The most obvious

iOS: Questions about camera information within GLKMatrix4MakeLookAt result

牧云@^-^@ 提交于 2019-12-10 11:12:28
问题 The iOS 5 documentation reveals that GLKMatrix4MakeLookAt operates the same as gluLookAt . The definition is provided here: static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { GLKVector3 ev = { eyeX, eyeY, eyeZ }; GLKVector3 cv = { centerX, centerY, centerZ }; GLKVector3 uv = { upX, upY, upZ }; GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv))); GLKVector3

Raphael transform animation not behaving

烈酒焚心 提交于 2019-12-10 09:43:18
问题 I'm doing an animated transform in Raphael (and Snap.svg, which does the same). If I apply a rotation to a basic element, it rotates normally as I would expect. However, if I already have a previous transform applied (even if its t0,0 or r0), the element seems to scale down and back up, as though it always has to fit in its previous bounding box or something. Here is an example fiddle var r1 = s.rect(0,0,100,100,20,20).attr({ fill: "red", opacity: "0.8", stroke: "black", strokeWidth: "2" });