# Square Root (Real)
Grammar — Square root(x)
Flags —Native
|Function
Returns the square root of a number.
# Arguments
fixed
— Value
Returns — fixed
native fixed SquareRoot(fixed x);
# Related
Category: Math / Arithmetic
- Absolute Value (Integer) —
int
— AbsI - Absolute Value (Real) —
fixed
— AbsF - Arithmetic (Integer)
- Bitwise Arithmetic (Integer)
- Arithmetic (Real)
- Arithmetic Multiple (Integer)
- Bitwise Arithmetic Multiple (Integer)
- Arithmetic Multiple (Real)
- Ceiling (Integer) —
int
— CeilingI - Ceiling (Real) —
fixed
— Ceiling - Clamp (Integer) —
int
— libNtve_gf_ArithmeticIntClamp - Clamp (Real) —
fixed
— libNtve_gf_ArithmeticRealClamp - Cycle
- Floor (Integer) —
int
— FloorI - Floor (Real) —
fixed
— Floor - Log2 (Integer) —
int
— Log2I - Log2 (Real) —
fixed
— Log2 - Log (Real) —
fixed
— libNtve_gf_Log - Modulo (Integer) —
int
— ModI - Modulo (Real) —
fixed
— ModF - Power (Integer) —
int
— PowI - Power (Real) —
fixed
— Pow - Round (Integer) —
int
— RoundI - Round (Real) —
fixed
— Round - Pow2 (Integer) —
int
— Pow2I - Pow2 (Real) —
fixed
— Pow2 - Square Root (Integer) —
int
— SquareRootI - Square Root (Real) —
fixed
— SquareRoot - Trunc (Integer) —
int
— TruncI - Trunc (Real) —
fixed
— Trunc
# Examples
campaigns/swarm.sc2campaign — base.sc2maps/maps/campaign/swarm/zexpedition02.sc2map/MapScript.galaxy:767
}
lv_offset = SquareRoot((lv_x*lv_x+lv_y*lv_y));
if ((lv_x == 0.0)) {
lv_angle = 90.0;
campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zexpedition02.sc2map — MapScript.galaxy:767
}
lv_offset = SquareRoot((lv_x*lv_x+lv_y*lv_y));
if ((lv_x == 0.0)) {
lv_angle = 90.0;
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/sc2epilogue03.sc2map/MapScript.galaxy:561
// Implementation
lv_normalizedCurrentAngle = gf_NormalizeVoidCrystalAngle(lp_index, lp_currentAngle);
return ((gv_voidCrystals[lp_index].lv_majorRadius * gv_voidCrystals[lp_index].lv_minorRadius) / SquareRoot((Pow((gv_voidCrystals[lp_index].lv_minorRadius * Cos(lv_normalizedCurrentAngle)), 2.0) + Pow((gv_voidCrystals[lp_index].lv_majorRadius * Sin(lv_normalizedCurrentAngle)), 2.0))));
}
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/sc2epilogue03.sc2map/MapScript.galaxy:2116
lv_sideC = DistanceBetweenPoints(gv_voidCrystals[lv_index].lv_center, gv_voidCrystals[lv_index].lv_zenith);
lv_angleB = ACos((((lv_sideA*lv_sideA)+(lv_sideC*lv_sideC)-(lv_sideB*lv_sideB))/(2*lv_sideA*lv_sideC)));
gv_voidCrystals[lv_index].lv_minorRadius = (((lv_sideA * lv_sideC) * Sin(lv_angleB)) / SquareRoot((Pow(lv_sideC, 2.0) - Pow((lv_sideA * Cos(lv_angleB)), 2.0))));
if ((gv_voidCrystals[lv_index].lv_rotatesCounterClockwise == true)) {
auto0413FD7D_ae = (360.0 + gv_voidCrystals[lv_index].lv_rotation);
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue03.sc2map — MapScript.galaxy:561
// Implementation
lv_normalizedCurrentAngle = gf_NormalizeVoidCrystalAngle(lp_index, lp_currentAngle);
return ((gv_voidCrystals[lp_index].lv_majorRadius * gv_voidCrystals[lp_index].lv_minorRadius) / SquareRoot((Pow((gv_voidCrystals[lp_index].lv_minorRadius * Cos(lv_normalizedCurrentAngle)), 2.0) + Pow((gv_voidCrystals[lp_index].lv_majorRadius * Sin(lv_normalizedCurrentAngle)), 2.0))));
}
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue03.sc2map — MapScript.galaxy:2116
lv_sideC = DistanceBetweenPoints(gv_voidCrystals[lv_index].lv_center, gv_voidCrystals[lv_index].lv_zenith);
lv_angleB = ACos((((lv_sideA*lv_sideA)+(lv_sideC*lv_sideC)-(lv_sideB*lv_sideB))/(2*lv_sideA*lv_sideC)));
gv_voidCrystals[lv_index].lv_minorRadius = (((lv_sideA * lv_sideC) * Sin(lv_angleB)) / SquareRoot((Pow(lv_sideC, 2.0) - Pow((lv_sideA * Cos(lv_angleB)), 2.0))));
if ((gv_voidCrystals[lv_index].lv_rotatesCounterClockwise == true)) {
auto0413FD7D_ae = (360.0 + gv_voidCrystals[lv_index].lv_rotation);
campaigns/voidstory.sc2campaign — base.sc2data/TriggerLibs/VoidCampaignMissionLib.galaxy:4837
lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_effectPosition[2] = WorldHeight(c_heightMapGround, EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
CameraShakeStart(1, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 2.5, 100.0, 0.1);
return true;
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/AILib.galaxy:89
diffx = PointGetX(p2) - PointGetX(p1);
diffy = PointGetY(p2) - PointGetY(p1);
length = SquareRoot(diffx * diffx + diffy * diffy);
if (length == 0.0) {
return p1;
mods/novastoryassets.sc2mod — base3.sc2maps/maps/campaign/nova/nova09.sc2map/MapScript.galaxy:4637
lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_effectPosition[2] = WorldHeight(c_heightMapGround, EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
CameraShakeStart(1, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 2.5, 100.0, 0.15);
return true;
mods/novastoryassets.sc2mod/base3.sc2maps/maps/campaign/nova/nova09.sc2map — MapScript.galaxy:4637
lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_effectPosition[2] = WorldHeight(c_heightMapGround, EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
CameraShakeStart(1, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 2.5, 100.0, 0.15);
return true;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:22605
}
UnitCreate(1, "ZerglingMengsk", 0, UnitGetOwner(EventPlayerEffectUsedUnit(c_effectUnitCaster)), PointWithOffsetPolar(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint), (SquareRoot(RandomFixed(0.0, 1.0)) * libNtve_gf_CatalogFieldValueGetAsReal(c_gameCatalogEffect, "MengskZergCalldownAreaDummy", "AreaArray[" + IntToString(0) + "].Radius", c_playerAny)), RandomFixed(0.0, 360.0)), RandomFixed(0.0, 360.0));
return true;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:22633
}
UnitCreate(1, "HydraliskMengsk", 0, UnitGetOwner(EventPlayerEffectUsedUnit(c_effectUnitCaster)), PointWithOffsetPolar(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint), (SquareRoot(RandomFixed(0.0, 1.0)) * libNtve_gf_CatalogFieldValueGetAsReal(c_gameCatalogEffect, "MengskZergCalldownAreaDummy", "AreaArray[" + IntToString(0) + "].Radius", c_playerAny)), RandomFixed(0.0, 360.0)), RandomFixed(0.0, 360.0));
return true;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:22661
}
UnitCreate(1, "MutaliskMengsk", 0, UnitGetOwner(EventPlayerEffectUsedUnit(c_effectUnitCaster)), PointWithOffsetPolar(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint), (SquareRoot(RandomFixed(0.0, 1.0)) * libNtve_gf_CatalogFieldValueGetAsReal(c_gameCatalogEffect, "MengskZergCalldownAreaDummy", "AreaArray[" + IntToString(0) + "].Radius", c_playerAny)), RandomFixed(0.0, 360.0)), RandomFixed(0.0, 360.0));
return true;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:22689
}
UnitCreate(1, "UltraliskMengsk", 0, UnitGetOwner(EventPlayerEffectUsedUnit(c_effectUnitCaster)), PointWithOffsetPolar(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint), (SquareRoot(RandomFixed(0.0, 1.0)) * libNtve_gf_CatalogFieldValueGetAsReal(c_gameCatalogEffect, "MengskZergCalldownAreaDummy", "AreaArray[" + IntToString(0) + "].Radius", c_playerAny)), RandomFixed(0.0, 360.0)), RandomFixed(0.0, 360.0));
return true;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:25330
lv_cameraPosition[1] = (PointGetY(lv_cameraTargetPoint)-(Cos(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, lv_cameraTargetPoint)+(Sin(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
CameraShakeStart(lv_player, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 5.0, 100.0, 0.5);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:29248
lv_effectPosition[1] = PointGetY(lv_effectTargetPoint);
lv_effectPosition[2] = WorldHeight(c_heightMapGround, lv_effectTargetPoint);
lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
CameraShakeStart(lv_player, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 2.5, 100.0, 0.1);
return true;