Linking to eigen cross product requires including the right eigen header

February 3rd, 2012

We were foiled for a while today by a strange eigen error. We successfully compiled a function that called eigen’s cross product function. But then linking to our compiled function resulted in linker errors within the cross product function. Our errors looked like this


"Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >::cross_product_return_type<Eigen::Matrix<double, 1, 3, 1, 1, 3> >::type Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >::cross<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&) const", referenced from:
      void igl::per_face_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&)in libigl.a(per_face_normals.o)

The workaround to this bug in eigen is to be sure to include the following header in the function compiling with the cross product call:


#include <Eigen/Geometry>

serendipity on the walls of the musée d’art et d’histoire

January 30th, 2012

mosset

modernity in japan

January 30th, 2012

modernity in japan

http://alecjacobson.com/art/digital/
http://alecjacobson.com/art/

intrinsic cotangent formula

January 23rd, 2012

Here’s a derivation of the cotangent of an angle α of a triangle ABC given just the lengths of each side of the triangle.
acute triangle

First of all we remind ourselves what cotangent is in terms of cosine and sine:


        cos α
cot α = ------
        sin α

Now look at cosine and sine separately. By the law of cosines we have that


a2 = b2 + c2 - 2bc cos α

Rearranging things we have that


        -a2 + b2 + c2
cos α = ------------
             2bc

Now looking at the sine, we start with the familiar area of the triangle treating b as the base.


     1
A = --- bh
     2

Using SOH-CAH-TOA, we replace the height:


     1
A = --- bc sin α
     2

Rearranging this we have:


         2A
sin α = ----
         bc

Now put the cosine and sine derivations together to get:


        cos α    -a2 + b2 + c2   bc
cot α = ------ = ------------  ----
        sin α        2bc        2A

Finally arriving at:


        -a2 + b2 + c2
cot α = ------------
             4A

hdlr

January 23rd, 2012

hdlr

http://alecjacobson.com/art/digital/
http://alecjacobson.com/art/

Shuffle rows of a matlab matrix

January 15th, 2012

Neat little trick using the keyword end:


M =  M(randperm(end),:);

Matlab colorbar without ticks

January 15th, 2012

Took a me a little bit to figure out how to make a color bar in matlab without tick marks.


hcb=colorbar;
set(hcb,'YTick',[])

Display wireframe mesh in matlab and save as vector graphics

January 14th, 2012

For our siggraph submission I wanted to overlay a 2D image with the wireframe of the mesh we use to deform it. In matlab I can display a 2D mesh (V,F) easily using:


trisurf(F,V(:,1),V(:,2),0*V(:,1));
view(2);
axis equal;

If I save this as .eps then I get a nice vector graphics version of my mesh.

But if I don’t want the filled faces to show up in the vector output, then when I try to save the following figure as a .eps file:


trisurf(F,V(:,1),V(:,2),0*V(:,1),'FaceAlpha',0);
view(2);
axis equal;

matlab just pretends to make a postscript vector file but instead its just a .eps file containing a raster image.

Here’s what I do to get a .eps vector graphics postscript file (which can then be turned into a PDF since output to PDF is broken in matlab):


E = edges(F);
plot([V(E(:,1),1) V(E(:,2),1)]',[V(E(:,1),2) V(E(:,2),2)]','k-');
view(2);
axis equal
set(gcf, 'Color', [1,1,1]);
set(gca, 'visible', 'off');

complimented by spam, complemented by spam

January 10th, 2012

complimented
                by spam
complemented

Screen capture a remote desktop into the remote clipboard

January 6th, 2012

I’m working a bit with Apple Remote Desktop now and I’m having trouble taking screen captures. It seems easy to take a screen capture that ends up as a file on or in the clipboard of the client side. But I’d rather be completely immersed in the remote computer, so ideally when I hit CMD+SHIFT+3 I’d get a screen shot the size and resolution of my remote desktop saved to the remote’s clipboard.

Here’s what I’m doing for now. I prepare my app that I want to screen capture then I switch to terminal and issue


echo "tell application \"skinning\" to activate" | osascript - && screencapture -c

This switches to my app and takes a screen capture into the clipboard.