This question was inspired by I was racially abused at a public park. What legal actions can I take?, although I am not asking specifically about that case. In that question someone, in Australia, was verbally abused in a seemingly racist manner. One of the answers quotes Australia's Federal Racial Discrimination Act 1975 (emphasis mine):
18C Offensive behaviour because of race, colour or national or ethnic origin
(1) It is unlawful for a person to do an act, otherwise than in private, if:
(a) the act is reasonably likely, in all the circumstances, to offend, insult, humiliate or intimidate another person or a group of people; and
(b) the act is done because of the race, colour or national or ethnic origin of the other person or of some or all of the people in the group.
However, in an edit the OP states he is "not of middle eastern decent but I do have a beard. I was wearing a robe like garment for a cultural function I was attending". This suggests (to my not-legally-trained brain) that even if Section 18C were to apply1 when the target was someone with a different "race, colour or national or ethnic origin", it might not apply if the target only gave the appearance of having a different "race, colour or national or ethnic origin".
1 For the particular incident from the linked question, it is possible that Section 18 would not apply in any case. This Wikipedia page suggests that for 18C to apply, courts require speech to have "... profound and serious effects, not to be likened to mere slights.". I don't know Australian case-law to know whether the incident described would fall under this requirement: for my question, assume that the acts would meet such requirements.
For brevity, I will use "target person" to mean someone "of/from a different race, colour or national or ethnic origin".
If someone carries out an alleged act of racial discrimination / intimidation / abuse (verbal or physical) against someone they believe to be a target person, would it be a defence (or would it not be an offence), if it turns out that the other party was not actually a target person, but just gave the appearance of being a target person?
Assumptions and Caveats
I do now want to debate about whether it is right or wrong to try to legislate in this way, whether it is "thought control taken too far", or whether other approaches, such as better education, may be better. If necessary, assume that appropriate legislators (parliament, congress, whatever) have decided through due democratic process that they want to punish the "appearance of being racist", whether the target actually is of a different ethnic group, or is mistaken for belonging to such a group by the perpetrator.
I assume that were the target(s) of the attack/abuse to actually be of/from a different race, colour or national or ethnic origin, there would be no question about guilt. The "doubt" is only whether legislation also applies when the perpetrator only believes their victim to be a target person.
As the original question was about Australia, an answer addressing Australian law would be welcome. As I'm from the UK, an answer from that perspective (specifically, English law) would also be welcome. However, providing it is not seen as being too broad, answers from other jurisdictions are also welcome.