Posts

Showing posts with the label Graphics

Calculating A LookAt Matrix

Answer : Note the example given is a left-handed, row major matrix . So the operation is: Translate to the origin first (move by - eye ), then rotate so that the vector from eye to At lines up with +z: Basically you get the same result if you pre-multiply the rotation matrix by a translation - eye : [ 1 0 0 0 ] [ xaxis.x yaxis.x zaxis.x 0 ] [ 0 1 0 0 ] * [ xaxis.y yaxis.y zaxis.y 0 ] [ 0 0 1 0 ] [ xaxis.z yaxis.z zaxis.z 0 ] [ -eye.x -eye.y -eye.z 1 ] [ 0 0 0 1 ] [ xaxis.x yaxis.x zaxis.x 0 ] = [ xaxis.y yaxis.y zaxis.y 0 ] [ xaxis.z yaxis.z zaxis.z 0 ] [ dot(xaxis,-eye) dot(yaxis,-eye) dot(zaxis,-eye) 1 ] Additional notes: Note that a viewing transformation is (intentionally) inverted : you multiply every vertex by this matrix to "move the world" so that the portion you want to s...

Crop An Inserted Image?

Image
Answer : You can crop your image with graphicx \documentclass{article} \usepackage{graphicx} \begin{document} % trim from left edge \includegraphics[trim={5cm 0 0 0},clip]{example-image-a} % trim from right edge \includegraphics[trim={0 0 5cm 0},clip]{example-image-a} \end{document} Use the trim option, which takes four space separated values. trim={<left> <lower> <right> <upper>} If you don’t give a unit, the package assumes bp i.e. big points to be the unit. After setting these values you must activate the cropping with clip=true or just clip . If you combine trim with height or something similar the image will be cropped and then resized. That means that the crop values must fit the original size. If found no solution to say crop to 50 % width. Update As Martin said in the comments you can use adjustbox to clip the image exactly by 50 %. Note that you must replace \includegraphics by \adjincludegraphics , to access the \width . \documentclass{artic...