POV-Ray : Newsgroups : povray.advanced-users : Normal vector deformation : Re: Normal vector deformation Server Time
30 Jul 2024 02:28:31 EDT (-0400)
  Re: Normal vector deformation  
From: Wlodzimierz ABX Skiba
Date: 15 Jan 2001 05:39:16
Message: <3a62d354$1@news.povray.org>
Rune wrote in message <3a60d0eb@news.povray.org>...
> I'm working on some deformation macros that deforms the point vectors and
> the normal vectors in a mesh.
>
> Deforming the points is easy. Deforming the normals is a bit more
> complicated.

yes, little more complicated ...

> To find a deformed normal I try to find the deformed points very close to
> the start point of the normal, and see how the direction changes. However, I
> can't figure out quite how to do it.

in the first version of my deform patch I had such calculation of normal - first
I had calculated n points around of deformed point on plane perpendicualr to the
base normal with distance d, and then deformed and calculated weighted normal of
achived virtual triangles

in symbolic code:

input:
  int n - n points around base/deformed point
  dbl d - distance beetwen points and base point
  vect P - base point
  vect N - normal in base point
  func deform( point ) - deformation as function

output:
  vect ND - normal after deformation
  vect D - point after deformation

code:
  dbl local a,b,c,i,j,p,l[n]
  vect A[n]

  p = N[Y]*N[Y]

  if ( p<(1.0-EPSILON) )
   {
    p=d/sqrt(1-p)
    A[0] = p * < N[Z], 0.0, N[X])
   }
  else
   {
     A[0] = < 0.0 , 0.0 , d >
   }

  for ( i = 1 ; i < n ; i = i + 1 )
   {
    A[i] = vaxis_rotate( A[0] , N , i * 2*pi/n )
   }

  D = deform( P )

  for ( i = 0 ; i < n ; i = i + 1 )
   {
    A[ i ] = deform( A[ i ] + P ) - D
    l[ i ] = vlength( A[ i ] )
   }

  DN=< 0.0, 0.0, 0.0 >

  for ( i=0 ; i < n ; i = i + 1 )
   {
    j = i+1
    j = ( j<n ) ? j : 0
    c = vlength( A[ i ] , A[ j ] )
    p = ( l[ i ] + l[ j ] + c ) / 2.0
    p = sqrt( p * ( p - l[i] ) * ( p - c ) * ( p - l[j] ) )
    DN = DN + p * vnormalize( vcross( A[ i ] , A[ j ] )
   }

  DN = vnormalize( DN )

I hope it helps

ABX


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.