Calculating for the scale factor

I’m trying to use the transform command to reduce my shape. To give an example of what i want to accomplish, Lets say I have shape 1 (no face) and would like to scale it down to be like shape 2

One thing I’ve tried is calculate for the area of both of the shape then divide them like this
smaller polygon area / larger polygon area but if I use it to scale it can’t get it to match shape 2
I understand that the scale that is needed for the transformation is the “global scale factor” but where do i get it from?

Are the shapes groups or component instances ?

If yes, then see these posts for getting the scales of instances:
How to check if 2 transformation are same? - #4 by DanRathbun
… or …
Face#area weird behavior - #6 by Aerilius

If not, get the scale by using the edges.

scale = edge1_of_shape2 / edge1_of_shape1

Area is a quadratic quantity, whereas the scale is linear. So you need to use the square root of the ratio of the areas. Math.sqrt(150.0/337.5) = 0.66666666

Actually the shapes are just an array points (Geom::Point3D) . So I cant reference it back to edges

You are dribble-feeding us details that affect the answer!

If all you have are points and you know how to pick corresponding pairs of points in the two shapes, you can use

point1.distance(point2)

to get how far apart they are. The ratio of distances will be the scale factor.

FYI: See Geom::Point3d#transform!()

Sorry if I missed some details just to be clear here’s a sample code that im using to generate the scaled down face

  def scale(original_pts, transformed_pts)
    scale_factor = calculate_scaling_factor(original_pts, transformed_pts) 
    # for now this is not returning the correct factor
    t = Geom::Transformation.new(scale_factor) 
    new_face = points.map{|pt|pt.transform(t) }
    Sketchup.active_model.entities.add_face(new_face)
  end
  # based on @slbaumgartner previous comment
  def calculate_scaling_factor(original_pts, transformed_pts)
    original_initial_length = original_pts[0].distance(original_pts[1])
    transformed_initial_length = transformed_pts[0].distance(transformed_pts[1])
    Math.sqrt((original_initial_length / transformed_initial_length).abs)  
  end

In this drawing I have a 15x15 inches box and i would like to generate or scale it down to 10x10 but the scaling still doesn’t get the exact dimension of 10x10. Based on the formula I would get a value of 0.816496580927726


and to add I’ve tried moving the edges to a component just not to bump into the face that i created that has the same dimension of my original points and found out that I should get ~0.67 for the scale
image_2021-12-12_083743
currently using a quadrilateral shape for now but the shape could be any polygon shaped points

Thanks already using it to transform all the points in the code. I think what im lacking now is how do i get the scaling factor that i should be using to generate the exact scale

You misunderstood me. You need a square root if you are comparing areas. If comparing distances you just need to divide.

Thanks! It returns the same shape now