How to identify the front and the back of a face?

When I looked into the composition of a face, I found a group of vertices. I was wondering how to tell its front and back?

And what is the intention of the direction of the vertices of a face? Is there a specific meaning if the vertices are grouped clockwise or counterclockwise? Or the direction does not matter at all?

Color. By default, the front of a face is chalky white; the back, a gray-blue. You can change the default colors in the Styles window. Click on the Edit button, then, in the row of 5 thumbnail images, click on the second from the left. Click in the windows next to the words Front and Back to change the color.

Careful, the request has been posted in developers / ruby API

1 Like

face.normal is the vector perpendicular to the face’s front.
The ‘winding’ of a face’s outer loop vertices is an unreliable indicator of the face’s front as if it’s flat at z=0 and has not be further manipulated it always faces downwards - irrespective of the ‘winding’ of its vertices.
Non-flat-z=0 faces do initially form logically depending of the vertices’ winding - ccw for outer loops and cw for inner loops.
If a face has been reversed [manually or in code] then its loops’ vertices winding and normal direction will not necessarily correspond as you might expect.
You can check if an edge is ‘reversed_in’ a face, which reveals that possibility…

1 Like

Faces in SketchUp are flat, 2-sided polygons with 3 or more sides.

They can be created a several different ways.
A special case exists for any face created on the ground plane, in which case the vertex order is ignored and the face is always facing down. Otherwise the vertex order take into account.

The vertices method is used to get an array of all of the vertices that bound the face. In this case the order of vertices in the array can be “random” and contains the outer and inner vertices too.

You can take a look:
the loops method is used to get an array of all of the loops that bound the face.
the outer loop method is used to retrieve the outer loop that bounds the face.

and check: Loop is a chain of Edges that bound a Face.
You will see an array of the vertices will define the loop in an ordered sequence.

1 Like

The vertex order means what? What is the difference between its clockwise and counterclockwise? Thanks.

The front of the face can be determined by comparing the face’s normal vector to the camera’s direction. I have found that perspective alters the view and can affect the outcome when the face is almost sideways to the view.

I have compensated for the perspective by creating a 3d point just in front of the face and one behind it and examined the distances from camera eye to both points.

Note: If the face is in a grouped object, then points and vectors in local coordinates should be transformed to world coordinates.

image

Thanks. I have understood that the front and back were determined by face.normal, camera’s direction, and if reversed.

I also want to known the relation of the vertex order and the face normal if exists. Supposing the vertex order is clockwise, what does it mean for the face?

The order of the vertices in outer loop of the face determining the face normal. (Or the other way around, they are closely related)
The face have a front side and back side. The normal vector of face is perpendicular to face and show the front direction.

There is no “definition” for reversed. The mentioning of “reversed” is relative, however you can reverse! the face if you do not like how it is oriented…

You can study something like this:

#create an edge representing a face normal
#  at first vertex of face
def add_normal(ent, face)
  pt_face = face.vertices[0].position
  pt_norm = pt_face.offset(face.normal)
  ent.entities.add_edges(pt_face, pt_norm)
end

def add_faces  
  model = Sketchup.active_model
  ents = model.active_entities
  pt0 = [0, 0, 0]
  pt1 = [1, 1, 0]
  pt2 = [0, 2, 2]
  
  #add face to separate group in order pt0-pt1-pt2
  gr0_2 = ents.add_group
  face_pt0_2 = gr0_2.entities.add_face(pt0, pt1, pt2)
  gr0_2.entities.add_text "face_pt0_2", pt2
  add_normal(gr0_2, face_pt0_2)
  gr0_2.name = "gr0_2"
  
  #add face to separate group in order pt2-pt1-pt0
  gr2_0 = ents.add_group
  face_pt2_0 = gr2_0.entities.add_face(pt2, pt1, pt0)
  gr2_0.entities.add_text "face_pt2_0", pt2
  add_normal(gr2_0, face_pt2_0)
  gr2_0.name = "gr2_0"
  
  # move the gr2_0 group a little to see...
  vector = Geom::Vector3d.new(0, 2, 0)
  tr = Geom::Transformation.translation(vector)
  ents.transform_entities(tr, gr2_0)
end
add_faces