Finding texture coordinates for plane

I am creating a 3D ray tracer and want to add textured planes.

My planes are stored using a position vector and a normal vector.

I want to use a square texture and map it repetitively onto the plane.

How do I figure out a transformation from points (3D vectors) on the plane and points (2D vectors) on a texture? Once I know how to do this transformation, I don’t think making it repetitive will be hard, as we can just apply modulo arithmetic.

I thought I could make a basis on the plane by calculating a vector B1 perpendicular to the normal, and then another one, B2, perpendicular to the normal and B1. But once I have these two vectors, I still don’t know how to express the point (which is the argument for the function below) in this basis.

Vector3 position, normal; Bitmap texture;  public override Vector3 GetColor(Vector3 point) {     int u = ?      int v = ?       return texture.GetPixel(u, v); }