SVD

darren_13
darren_13 Member, Developers Posts: 120 PRO
I have a vector which is the normal to a plane to create another plane x distance in the normal from the original plane I want to find the unit vector of the normal. I wanted to use svd but I can't figure how to use is where do I put the 'u' in svd? my code looks like this:

//Make Plane normal<div>&nbsp; &nbsp; &nbsp; &nbsp; var centerPlane = evFaceTangentPlane(context, {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "face" : definition.selectPlane,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "parameter" : vector(0.5, 0.5)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var normal = centerPlane.normal</div>

Comments

  • darren_13
    darren_13 Member, Developers Posts: 120 PRO
    once again don't know why this formatting has changed
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,123 image
    Hi Darren, I'm not sure I understand the question. You already have the unit normal in your code above. Also what is SVD? (Hope I don't get embarrassed for not knowing what that is!)
    Senior Director, Technical Services, EMEA
  • darren_13
    darren_13 Member, Developers Posts: 120 PRO
    ok looking back over the documentation it appears that I do have unit normal that I'm after, so now the question is could I have used svd? in the documentation, 

    svd (m is Matrix) returns map

    Compute the singular value decomposition of a matrix, i.e. s, u, and v, where m == u * s * v and s is a diagonal matrix of singular values.

    where u would give me a unit vector? how would I set this up?

    It would be really handy if I could view what my variables and constants contain like I do in matlab? because I find myself asking quite a lot of questions I could answer myself if I could see what is being created.

    Thanks for your speedy response :) 

    Darren Lynch

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,274 image
    Darren, centerPlane.normal is already unit-length, so you don't need to do anything with it.  If it were not unit-length, you could use the normalize function to make it unit-length.  The SVD is for other more mathy things (computing matrix rank, orthonormalizing a matrix, computing a pseudo-inverse, principal component analysis, solving poorly conditioned linear systems, finding low-rank matrix approximations, to name a few).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • darren_13
    darren_13 Member, Developers Posts: 120 PRO
    ok, thanks ilya! :smile: