-2

I have a 3d model and I want to recalculate the normal when the model is scaled (non uniformly). For example, I have a 3d model and when i scale non uniformly, the normal should be affected

1) Figure 1, the model is not scaled. 2) Figure 2, the model is scaled and the normal is affected. (N is the normal).

normals

magallanes
  • 6,583
  • 4
  • 54
  • 55
  • 1
    (Did not downvote) Simply scale the normal by the same proportions and normalize. – meowgoesthedog Mar 31 '18 at 01:53
  • Are you specifically working in C#? Using Unity3D? Do you need a formula or a code representation? What have you tried in code? – JamesFaix Mar 31 '18 at 02:29
  • Also, I'm not sure what `quaternions` has to do with an issue of scaling. – JamesFaix Mar 31 '18 at 02:30
  • I am using c# so I am free to use whatever expression that I want too. And quaternion is usually used for doing a 3d conversion. – magallanes Mar 31 '18 at 11:03
  • @meowgoesthedog Let's say the next normal(0.0000,0.9008,-0.4343) (x,y,z), how i can obtain the proportion?.. If I scale for 200%,200%,200%, then the normal shouldn't be affected.However, if I scale by 100%,1000%,100%, then it's affected. – magallanes Mar 31 '18 at 11:08
  • 1
    Did you read my comment? Scale + *normalize*. If you are to scale something then you must already have the proportions. – meowgoesthedog Mar 31 '18 at 11:27
  • @meowgoesthedog yes, I was working on it. Thanks. – magallanes Mar 31 '18 at 11:51
  • Normals should NOT be updated during scaling of model. Normal represents Direction only and have magnitude 1.0 . – minorlogic Apr 02 '18 at 08:58
  • Normals should be updated if the scale is not proportional. You can see the image. 1) is 45º while 2) (that was scaled in the Y-axis) is 35º – magallanes Apr 02 '18 at 12:05

1 Answers1

-1
    public Vector ModifyNormal(Vector v)
    {
        var re = new Vector();
        re.x = v.x  * xScale; 
        re.y = v.y  * yScale; 
        re.z = v.z * zScale;
        double magnitude =Math.Sqrt(re.x * re.x + re.y * re.y + re.z * re.z);
        // normalizing
        re.x = re.x / magnitude;
        re.y = re.y / magnitude;
        re.z = re.z / magnitude;
        return re;
    }
magallanes
  • 6,583
  • 4
  • 54
  • 55
  • This solution works and it was downvoted. C'MON!. It's the reason why StackOverflow is going down: nerds!. – magallanes Apr 02 '18 at 12:03
  • Sorry, this is my miss. I didn't noted that scaling in NONuniform. I must wait some time, before i be able to revert it. – minorlogic Apr 02 '18 at 14:27