transformation

How to get rotation, translation, shear from a 3x3 Homography matrix in c#

自作多情 提交于 2019-11-28 10:33:27
I calculated the 3x3 homography matrix and I need to get rotation, translation, shear and scale to use them as parameters in the windows8 media element attributes ?! Tom Larkworthy see https://math.stackexchange.com/questions/78137/decomposition-of-a-nonsquare-affine-matrix def getComponents(normalised_homography): '''((translationx, translationy), rotation, (scalex, scaley), shear)''' a = normalised_homography[0,0] b = normalised_homography[0,1] c = normalised_homography[0,2] d = normalised_homography[1,0] e = normalised_homography[1,1] f = normalised_homography[1,2] p = math.sqrt(a*a + b*b)

XSLT, Renaming Elements using mapping table based on Attribute's value

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 09:50:22
问题 How to rename the elements according to a mapping table based on attribute's of the element? Any suggestions would be much appreciated. Maybe a XSLT 2.0 template and modifying the mapping table for better solution? Many thanks in advance Thomas Original XML: <transaction> <records type="1" > <record type="1" > <field number="1" > <item>223</item> </field> <field number="2" > <item>456</item> </field> </record> </records> <records type="14" > <record type="14" > <field number="1" > <item>777<

PHP strtr vs str_replace benchmarking

旧巷老猫 提交于 2019-11-28 09:27:13
问题 I'm curious what the most performant method of doing string transformations is. Given a n input string and a set of translations, what method is the most efficient in general? I currently use strtr() , but have tested various looping methods, str_replace() with an array, etc. The strtr() method benchmarks the fastest on my system, depending on the translations, but I'm curious if there are faster methods I haven't thought of yet. If it's pertinent, my particular use case involves transforming

Hibernate SQL transformation fails for Enum field type

。_饼干妹妹 提交于 2019-11-28 09:24:55
I am using a SQL query and then transforming the result using Hibernates's Transformers.aliasToBean() . One of the columns in my query is an enum. The transformation somehow fails for the enum. What should I do? Which datatype should I use? I want more than 1 character to transform the result into my enum type. This is how the simplified version of my query/code looks like ( b is an enum in the table profiles): session.createSQLQuery("select a, b from profiles").setResultTransformer(Transformers.aliasToBean(Profile.class)) .list(); Exception : expected type: Foo.ProfileStateEnum, actual value:

XmlResolver: XSLT compiler error

有些话、适合烂在心里 提交于 2019-11-28 09:09:58
问题 I have troubles with XmlResolver class. I have a few XSLT files saved in MS SQL database in xml datatype column. I'm trying to write a XmlResolver class implementation, that would load the text from database instead of from the files. But I'm getting XSLT compiler error. Here is very simple example (text of both input and xslt is hardcoded here): static void Main(string[] args) { string xslt = @"<?xml version=""1.0"" encoding=""utf-8""?> <xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www

Opengl order of matrix transformations

╄→гoц情女王★ 提交于 2019-11-28 06:00:28
Let's say I have a blue 3D box (where the top side is red colored). Now I call glScalef(1, 10, 1). Then I call glRotatef(90, 0, 1, 0). Then i render the cube. What i expected is to see the the red side facing and stretched towards the screen (along the Y axis of the model). But what im seeing is this: The red side is facing the screen (as expected). But the stretch is occurring on the Y axis of the view space (not the model). I do know that if I set the scale along the Z axis, then i'll get the right result. But my confusion is that i thought scaling up on the Y axis, then rotating the box,

Autolayout crash when applying transform: Assertion failure in -[layoutSublayersOfLayer:]

孤街浪徒 提交于 2019-11-28 04:16:44
问题 I have a custom view that display a UILabel in the bottom right corner. The view is setup in a method called from both initWithCoder: and initWithFrame: like this: MCLabel* likesLabel = [[MCLabel alloc] init]; likesLabel.mc_textPadding = UIEdgeInsetsMake(0, 10, 0, 10); likesLabel.font = [UIFont fontWithName:@"FontAwesome" size:12.f]; [likesLabel setText:@"test"]; likesLabel.numberOfLines = 2; likesLabel.backgroundColor = [UIColor colorWithWhite:1 alpha:.8]; likesLabel.textColor = UIColor

Perspective transform of SVG paths (four corner distort)

心已入冬 提交于 2019-11-28 04:09:31
How is it possible to distort paths in SVG in browser so that they are distorted to certain perspective using possibly javascript or css? The perspective distort can be made easily in Photoshop, Illustrator etc, but how about browsers? This is source path: And this is the path after transformation: This is my drag distort proposal ( share you knowledge, Q&A-style ). Live example is in http://jsfiddle.net/xjHUk/278/ and the main code is this: (only output window: http://jsfiddle.net/xjHUk/279/embedded/result/ ) function transferPoint (xI, yI, source, destination) { var ADDING = 0.001; // to

SQLAlchemy Column to Row Transformation and vice versa — is it possible?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 01:20:02
问题 I'm looking for a SQLAlchemy only solution for converting a dict received from a form submission into a series of rows in the database, one for each field submitted. This is to handle preferences and settings that vary widely across applications. But, it's very likely applicable to creating pivot table like functionality. I've seen this type of thing in ETL tools but I was looking for a way to do it directly in the ORM. I couldn't find any documentation on it but maybe I missed something.

Combine constraints and data transformers

跟風遠走 提交于 2019-11-27 23:40:20
I would like to do something looking like what is done in How to use Data Transformers tutorial. But I would like to add a process and I can't find any example. In the symfony tutorial, data transformation is about changing an issue number to an Issue object. This is done in the reverseTransform() function of IssueToNumberTransformer public function reverseTransform($number) { if (!$number) { return null; } $issue = $this->om ->getRepository('AcmeTaskBundle:Issue') ->findOneBy(array('number' => $number)) ; if (null === $issue) { throw new TransformationFailedException(sprintf( 'An issue with