Plane in 3d viewport and 2d offet

Hi, if I want to move a vertex in 3d space 1 unit to the left side (in 2d the X axis) I would add a

Vector(-1,0,0)

if the vertex is on a plane Front orthographic. But if the point is on a plane somewhere in 3d viewport (rotated) and I want to bring the vertex 1 unit to the “left” side along this plane, how can I do this with Python and in general.

I know the normal of the plane and I know that the vertex that I want to move is on the plane.

Thx in advance!

import bpy
from mathutils import Vector

def vert_move_local(source_plane, vertex_obj,  direction_vector):

	inv = source_plane.matrix_world.inverted()
	v = direction_vector * inv
	vertex_obj.data.vertices[0].co  +=  v


vertex_obj = bpy.context.object
source_plane = bpy.data.objects["Plane.001"]
vert_move_local(source_plane, vertex_obj,  Vector((-1,0,0)))


Thx a lot for the code, this gives me a good starting-point and I understood it. Actually my wording was not correct, I talked about a plane, but I didnt mean a plane-object (mesh), I meant a virtual plane in the viewport (view plane).
But of course it is the same concept: What I need is the inverted world matrix of the viewport plane (perhaps I can ge this from the region3d?), multiply it with my normal vector (BTW: Isnt this the @ operator for multiply since Blender 2.8) and then I can add it locally, right?

Perhaps I explain it with a picture. I painted a circle into the 3d viewport:

image

Now I want to move the center-point (Vector) to the local X position 0. But the view is rotated.

What I did is to get the current view_marix and multiplied it with the current center point of the circle:

vm = self._view_context._view_mat
v = self._center.copy()
v = v @ vm

This seems to give me the local Vector of the center, ok. Now O want to set the X to 0:

v[0] = 0

And how can I reset the self._center then so that just the X pos is set, because the self._center is world matrix:-)

Wrote this function to center a vertex for a particular axis according to the current view matrix:

def set_center(self, axis, vec_center):

        rot_mat = self._view_context._view_mat

        v = rot_mat @ vec_center

        if axis == "N":

            vec_center = Vector((0,0,0))

        else:

            if axis == "X":

                v = Vector((-v[0],0,0))

            elif axis == "Y":

                v = Vector((0,-v[1],0))

            vec_center += rot_mat.inverted() @ v