# bug #44771: coords.scale along arbitrary direction

 Submitted by: gianluca de santis Submitted on: Wed 08 Apr 2015 01:20:50 PM UTC Category: Core Severity: 2 - Minor Item Group: Feature request Status: None Privacy: Public Assigned to: None Open/Closed: Open

You are not logged in

## Discussion

Thu 09 Apr 2015 08:01:47 AM UTC, comment #3:

Previous comment seems in agreement with wikipedia:
http://en.wikipedia.org/wiki/Scaling_(geometry)

From the suggested mode of the new stretch (or directional scaling) method I would remove the mode dir=None and always require the specification of one single direction of stretching. Also I would rename the parameter scale with stretch:

def stretch(self,stretch,dir=None,center=None)

About the difference between scale and stretch:

- scaling refers to cartesian axes (e.g. x axis in mm, y axis is cm, z axis in inch) and can allow conversion of the unit of length

- stretch is a transformation of the geometry. We could generalize it into a non-linear stretch by using a power of the distance (in this case the transformation will probably become non-affine).

def stretch(self,stretch,dir=None,center=None,power=1.)

Wed 08 Apr 2015 06:12:25 PM UTC, comment #2:

I think this is a useful function, but I am not sure how we should implement it. It seems natural to include it in the existing scale method, however that has already a complex interface including a 'dir' argument with a different meaning.
Adding another 'dir' option will probably make the method too complex.

These are the possibilies of the current scale:

- scale=s, dir=None
- scale=s, dir=i
- scale=s, dir=[i,...]
- scale=[sx,sy,sz], dir=None

Above this there are the extra center= and inplace= arguments.
The latter is not fully implemented, only for center=None.

Adding the new proposal would mean that we have an extra mode:

- scale=s, dir=[x,y,z]

This could be confused with the second mode above. It would however be consistent with other methods that allow either dir=i or dir=[x,y,z].

On the other hand, the dir=[i,...] option is very efficient if you want to scale in two directions only. And it is a basic operation that has been in pyFormex for a long time, so we should not change this lightly.

Maybe we should instead create a NEW method stretch(scale,dir,center) which the modes:
- scale=s, dir=None
- scale=s, dir=i
- scale=s, dir=[x,y,z]
and the extra argument center= (perhaps not the inplace: the computation of distances will anyhow already use up memory).

Benedict Verhegghe <bverheg>
Wed 08 Apr 2015 01:36:20 PM UTC, comment #1:

This is a draft of the scaling along an arbitrary direction:

def scale(self,scale,dir=None,center=None):
d = self.distanceFromPlane(p=center, n=dir).reshape(-1, 1)
return self+(scale-1.)*d*dir

Could this be merged into coords.scale?

Wed 08 Apr 2015 01:20:50 PM UTC, original submission:

Is it possible to scale an object along an arbitrary axis?

All points should be displaced along a direction 'dir' of a distance proportional to their distance from a neutral plane, multiplied by the 'scale'.

geom1 = geom0.scale(scale=..., dir=..., center=...)

- scale = float

- dir = direction vector consisting of 3 floats (ie. the normal of the neutral plane)

- center = a point on the 'neutral' plane (all point on this plane will not be transformed)

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by bverheg (Posted a comment)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only logged-in users can vote.

## History

No changes have been made to this item